javascript MDL-16673 Removed all removeable uses of CFG->javascript

In doing this I was able to eliminate the need for javascript.php files, now removed.
I will also be filing several subtasks to clean up the linked to JS files in OUTPUT as well
as all instance of the old style of focusing.
This commit is contained in:
samhemelryk 2009-07-07 09:09:16 +00:00
parent e4e7044acd
commit e11a8328b3
10 changed files with 91 additions and 199 deletions

View file

@ -0,0 +1,20 @@
window.onresize = function() {
resizeiframe(imsdata.jsarg, imsdata.customcorners);
};
window.name='ims-cp-page';
// Set Interval until ims-containerdiv and (ims-contentframe or ims-contentframe-no-nav) is available
function waiting() {
var cd = document.getElementById('ims-containerdiv');
var cf = document.getElementById('ims-contentframe');
var cfnv = document.getElementById('ims-contentframe-no-nav');
if (cd && (cf || cfnv)) {
resizeiframe(imsdata.jsarg, imsdata.customcorners);
clearInterval(ourInterval);
return true;
}
return false;
}
var ourInterval = setInterval('waiting()', 100);

View file

@ -1,53 +0,0 @@
<?php /// $Id $
/// Load IMS required Javascript libraries, adding them
/// before the standard one ($standard_javascript)
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
/// We use this globals to be able to generate the proper JavaScripts
global $jsarg, $standard_javascript;
/// Let's know if we are using a customcorners theme. It implies new calculations
/// within the resizeiframe function.
// TODO this will no longer work. We have the more general mechanism using renderers/renderer_factories
// to determine what HTML is output. If this JavaScript is really still necessary, then we will have
// to find another way to handle this.
if (!empty($THEME->customcorners)) {
$customcorners = 'true';
} else {
$customcorners = 'false';
}
/// Load IMS needed JavaScript
/// The dummy LMS API hack to stop some SCORM packages giving errors.
echo "<script type=\"text/javascript\" src=\"$CFG->wwwroot/mod/resource/type/ims/dummyapi.js\"></script>\n";
/// The resize iframe script
echo " <script type=\"text/javascript\" src=\"$CFG->wwwroot/mod/resource/type/ims/resize.js\"></script>\n";
echo " <script type=\"text/javascript\">
window.onresize = function() {
resizeiframe($jsarg, $customcorners);
};
window.name='ims-cp-page';
// Set Interval until ims-containerdiv and (ims-contentframe or ims-contentframe-no-nav) is available
function waiting() {
var cd = document.getElementById('ims-containerdiv');
var cf = document.getElementById('ims-contentframe');
var cfnv = document.getElementById('ims-contentframe-no-nav');
if (cd && (cf || cfnv)) {
resizeiframe($jsarg, $customcorners);
clearInterval(ourInterval);
return true;
}
return false;
}
var ourInterval = setInterval('waiting()', 100);
</script>\n";
/// Load standard JavaScript
include("$standard_javascript");
?>

View file

@ -44,13 +44,16 @@
$direction = ' dir="ltr"';
}
/// Conditional argument to pass to IMS JavaScript. Need to be global to retrieve it from our custom javascript! :-(
global $jsarg;
$jsarg = 'true';
/// Define $CFG->javascript to use our custom javascript. Save the original one to add it from ours. Global too! :-(
global $standard_javascript;
$standard_javascript = $CFG->javascript; // Save original javascript file
$CFG->javascript = $CFG->dirroot.'/mod/resource/type/ims/javascript.php'; //Use our custom IMS javascript code
if (!empty($THEME->customcorners)) {
$customcorners = 'true';
} else {
$customcorners = 'false';
}
$PAGE->requires->data_for_js('imsdata', Array('customcorners'=>$customcorners, 'jsarg'=>$jsarg));
$PAGE->requires->js('mod/resource/type/ims/dummyapi.js')->in_head();
$PAGE->requires->js('mod/resource/type/ims/resize.js')->in_head();
$PAGE->requires->js('mod/resource/type/ims/ims.js')->in_head();
/// The output here

View file

@ -315,7 +315,7 @@ class resource_ims extends resource_base {
* @param CFG global object
*/
function display() {
global $CFG, $THEME, $USER;
global $CFG, $THEME, $USER, $PAGE;
require_once($CFG->libdir.'/filelib.php');
@ -456,15 +456,20 @@ class resource_ims extends resource_base {
if (empty($frameset) || $frameset=='ims') {
/// Conditional argument to pass to IMS JavaScript. Need to be global to retrieve it from our custom javascript! :-(
global $jsarg;
$jsarg = 'false';
if (!empty($this->parameters->navigationmenu)) {
$jsarg = 'true';
}
/// Define $CFG->javascript to use our custom javascript. Save the original one to add it from ours. Global too! :-(
global $standard_javascript;
$standard_javascript = $CFG->javascript; // Save original javascript file
$CFG->javascript = $CFG->dirroot.'/mod/resource/type/ims/javascript.php'; //Use our custom IMS javascript code
if (!empty($THEME->customcorners)) {
$customcorners = 'true';
} else {
$customcorners = 'false';
}
$PAGE->requires->data_for_js('imsdata', Array('customcorners'=>$customcorners, 'jsarg'=>$jsarg));
$PAGE->requires->js('mod/resource/type/ims/dummyapi.js')->in_head();
$PAGE->requires->js('mod/resource/type/ims/resize.js')->in_head();
$PAGE->requires->js('mod/resource/type/ims/ims.js')->in_head();
/// moodle header
if ($resource->popup) {