MDL-22951 - do popup blocking detection, and fix double open on popup
This commit is contained in:
@@ -199,6 +199,7 @@ $string['popup'] = 'New window';
|
||||
$string['popupblockmessage'] = 'If a pop-up window doesn\'t appear, please enable pop-ups in your browser.';
|
||||
$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 module from playing. Please check your browser settings, before starting again.';
|
||||
$string['position_error'] = 'The {$a->tag} tag can\'t be child of {$a->parent} tag';
|
||||
$string['preferencesuser'] = 'Preferences for this report';
|
||||
$string['preferencespage'] = 'Preferences just for this page';
|
||||
|
||||
+15
-10
@@ -23,9 +23,7 @@
|
||||
|
||||
M.mod_scorm = {};
|
||||
|
||||
M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, window_options, window_width, window_height, launch_sco) {
|
||||
|
||||
var popup_winHandle = false;
|
||||
M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launch_sco) {
|
||||
|
||||
if (hide_nav == 0) {
|
||||
scorm_hide_nav = false;
|
||||
@@ -81,13 +79,6 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
var api_url = M.cfg.wwwroot + '/mod/scorm/api.php?' + node.title;
|
||||
document.getElementById('external-scormapi').src = api_url;
|
||||
}
|
||||
|
||||
// make the popup work
|
||||
if (window_name) {
|
||||
popup_winHandle = window.open('', window_name, window_options, window_width, window_height);
|
||||
popup_winHandle.location.href = url_prefix + node.title;
|
||||
popup_winHandle.resizeTo(window_width, window_height);
|
||||
}
|
||||
|
||||
var content = new YAHOO.util.Element('scorm_content');
|
||||
try {
|
||||
@@ -95,6 +86,13 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
// and also it has some restrictions on DOM access from object tag
|
||||
if (window_name || node.title == null) {
|
||||
var obj = document.createElement('<iframe id="scorm_object" src="">');
|
||||
if (window_name) {
|
||||
var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
|
||||
if(! mine) {
|
||||
alert(M.str.scorm.popupsblocked);
|
||||
}
|
||||
mine.close()
|
||||
}
|
||||
}
|
||||
else {
|
||||
var obj = document.createElement('<iframe id="scorm_object" src="'+url_prefix + node.title+'">');
|
||||
@@ -110,6 +108,13 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, windo
|
||||
if (!window_name && node.title != null) {
|
||||
obj.setAttribute('data', url_prefix + node.title);
|
||||
}
|
||||
if (window_name) {
|
||||
var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
|
||||
if(! mine) {
|
||||
alert(M.str.scorm.popupsblocked);
|
||||
}
|
||||
mine.close()
|
||||
}
|
||||
}
|
||||
var old = YAHOO.util.Dom.get('scorm_object');
|
||||
if (old) {
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
function scorm_openpopup(url,name,options,width,height) {
|
||||
fullurl = M.cfg.wwwroot + '/mod/scorm/' + url;
|
||||
windowobj = window.open(fullurl,name,options);
|
||||
if (!windowobj) {
|
||||
return;
|
||||
}
|
||||
if ((width==100) && (height==100)) {
|
||||
// Fullscreen
|
||||
windowobj.moveTo(0,0);
|
||||
@@ -14,4 +17,4 @@ function scorm_openpopup(url,name,options,width,height) {
|
||||
windowobj.resizeTo(width,height);
|
||||
windowobj.focus();
|
||||
return windowobj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@
|
||||
$PAGE->requires->string_for_js('toc', 'scorm');
|
||||
$PAGE->requires->string_for_js('hide', 'moodle');
|
||||
$PAGE->requires->string_for_js('show', 'moodle');
|
||||
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
|
||||
|
||||
$name = false;
|
||||
|
||||
@@ -258,7 +259,7 @@ if (!isset($result->toctitle)) {
|
||||
$result->toctitle = get_string('toc', 'scorm');
|
||||
}
|
||||
|
||||
$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $scorm->options, $scorm->width, $scorm->height, $sco->id));
|
||||
$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $sco->id));
|
||||
|
||||
|
||||
$completion=new completion_info($course);
|
||||
|
||||
Reference in New Issue
Block a user