mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
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:
parent
e4e7044acd
commit
e11a8328b3
10 changed files with 91 additions and 199 deletions
|
@ -1044,6 +1044,16 @@ function focuscontrol(controlid) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers keyboard focus to an HTML element based on the old style style of focus
|
||||
* This function should be removed as soon as it is no longer used
|
||||
*/
|
||||
function old_onload_focus(parentname, controlname) {
|
||||
if (window[parentname]) {
|
||||
window[parentname][controlname].focus();
|
||||
}
|
||||
}
|
||||
|
||||
function scroll_to_end() {
|
||||
window.scrollTo(0, 5000000);
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Load up any required Javascript libraries
|
||||
*
|
||||
* @package moodlecore
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
?>
|
||||
|
||||
<!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(<?php echo $CFG->httpswwwroot ?>/lib/csshover.htc);} /*]]>*/</style>-->
|
||||
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/javascript-static.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/javascript-mod.php"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/overlib/overlib.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/overlib/overlib_cssstyle.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/cookies.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/ufo.js"></script>
|
||||
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/dropdown.js"></script>
|
||||
|
||||
<script type="text/javascript" defer="defer">
|
||||
//<![CDATA[
|
||||
setTimeout('fix_column_widths()', 20);
|
||||
//]]>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
<?php
|
||||
if (!empty($focus)) {
|
||||
if(($pos = strpos($focus, '.')) !== false) {
|
||||
//old style focus using form name - no allowed inXHTML Strict
|
||||
$topelement = substr($focus, 0, $pos);
|
||||
echo "addonload(function() { if(document.$topelement) document.$focus.focus(); });\n";
|
||||
} else {
|
||||
//focus element with given id
|
||||
echo "addonload(function() { if(el = document.getElementById('$focus')) el.focus(); });\n";
|
||||
}
|
||||
$focus = false; // Prevent themes from adding it to body tag which breaks addonload(), MDL-10249
|
||||
}
|
||||
?>
|
||||
//]]>
|
||||
</script>
|
|
@ -1561,16 +1561,30 @@ class moodle_core_renderer extends moodle_renderer_base {
|
|||
// Check if a periodic refresh delay has been set and make sure we arn't
|
||||
// already meta refreshing
|
||||
if ($this->metarefreshtag=='' && $this->page->periodicrefreshdelay!==null) {
|
||||
$metarefesh = '<meta http-equiv="refresh" content="%d;url=%s" />';
|
||||
$output .= sprintf($metarefesh, $this->page->periodicrefreshdelay, $this->page->url->out());
|
||||
$output .= '<meta http-equiv="refresh" content="'.$this->page->periodicrefreshdelay.';url='.$this->page->url->out().'" />';
|
||||
}
|
||||
|
||||
// TODO get rid of $CFG->javascript. We should be able to do everything
|
||||
// with $PAGE->requires.
|
||||
ob_start();
|
||||
include($CFG->javascript);
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->page->requires->js('lib/javascript-static.js')->in_head();
|
||||
$this->page->requires->js('lib/javascript-mod.php')->in_head();
|
||||
$this->page->requires->js('lib/overlib/overlib.js')->in_head();
|
||||
$this->page->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
|
||||
$this->page->requires->js('lib/cookies.js')->in_head();
|
||||
$this->page->requires->js('lib/ufo.js')->in_head();
|
||||
$this->page->requires->js('lib/dropdown.js')->in_head();
|
||||
$this->page->requires->js_function_call('setTimeout', Array('fix_column_widths()', 20));
|
||||
|
||||
$focus = $this->page->focuscontrol;
|
||||
if (!empty($focus)) {
|
||||
$pos = strpos($focus, '.');
|
||||
if($pos !== false) {
|
||||
// Old style of focus, bad way to do it
|
||||
debugging('This code is using the old style focus event, Please update this code to focus on an element id', DEBUG_DEVELOPER);
|
||||
$this->page->requires->js_function_call('old_onload_focus', Array(substr($focus, 0, $pos), substr($focus, $pos)));
|
||||
} else {
|
||||
// Focus element with given id
|
||||
$this->page->requires->js_function_call('focuscontrol', Array($focus));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the meta tags from the themes if any were requested.
|
||||
$output .= $this->page->theme->get_meta_tags($this->page);
|
||||
|
|
|
@ -464,7 +464,6 @@ global $SCRIPT;
|
|||
|
||||
/// Location of standard files
|
||||
$CFG->wordlist = $CFG->libdir .'/wordlist.txt';
|
||||
$CFG->javascript = $CFG->libdir .'/javascript.php';
|
||||
$CFG->moddata = 'moddata';
|
||||
|
||||
/// Create the $PAGE global.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue