Merge branch 'master_MDL-43247' of git://github.com/danmarsden/moodle
This commit is contained in:
+36
-33
@@ -1,6 +1,6 @@
|
||||
M.mod_scormform = {};
|
||||
M.mod_scormform.init = function(Y) {
|
||||
var scormform = document.getElementById('scormviewform');
|
||||
var scormform = Y.one('#scormviewform');
|
||||
var cwidth = scormplayerdata.cwidth;
|
||||
var cheight = scormplayerdata.cheight;
|
||||
var poptions = scormplayerdata.popupoptions;
|
||||
@@ -8,8 +8,9 @@ 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+"¤torg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey;
|
||||
var launch_url = M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"¤torg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey+"&display=popup";
|
||||
var course_url = scormplayerdata.courseurl;
|
||||
var winobj = null;
|
||||
|
||||
poptions = poptions + ',resizable=yes'; // Added for IE (MDL-32506).
|
||||
|
||||
@@ -25,33 +26,35 @@ 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.opener) {
|
||||
// Redirect the parent window to the course homepage.
|
||||
parent.window.location = course_url;
|
||||
}
|
||||
}, 800)
|
||||
}
|
||||
|
||||
var scormredirect = function (winobj) {
|
||||
winobj.onload = function () {
|
||||
|
||||
// Hide the form and toc if it exists - we don't want to allow multiple submissions when a window is open.
|
||||
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 but for some reason the events
|
||||
// below aren't triggered.
|
||||
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.
|
||||
winobj.onunload = function () {
|
||||
// Onunload is called multiple times in the SCORM window - we only want to handle when it is actually closed.
|
||||
setTimeout(function() {
|
||||
if (!winobj.opener) {
|
||||
// Redirect the parent window to the course homepage.
|
||||
parent.window.location = course_url;
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
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() {
|
||||
@@ -61,17 +64,17 @@ M.mod_scormform.init = function(Y) {
|
||||
}
|
||||
|
||||
if (launch == true) {
|
||||
launch_url = launch_url+"&display=popup";
|
||||
var winobj = window.open(launch_url,'Popup', poptions);
|
||||
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) {
|
||||
scormform.onsubmit = function() {
|
||||
var winobj = window.open('', 'Popup', poptions);
|
||||
Y.on('submit', function(e) {
|
||||
winobj = window.open(launch_url, 'Popup', poptions);
|
||||
this.target='Popup';
|
||||
scormredirect(winobj);
|
||||
}
|
||||
e.preventDefault();
|
||||
}, scormform);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user