From e29380f3c417001aaa52ec4db8871ddc93823206 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 26 Jun 2009 09:38:14 +0000 Subject: [PATCH] themes: MDL-19077 fix install regression --- admin/index.php | 3 ++- admin/report/unittest/test_tables.php | 3 --- lib/deprecatedlib.php | 2 +- lib/javascript-static.js | 18 +++++++++++++++++- lib/scroll_to_page_end.js | 17 ----------------- lib/upgradelib.php | 9 ++++++--- 6 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 lib/scroll_to_page_end.js diff --git a/admin/index.php b/admin/index.php index e833f1842b3..22e60a51d23 100644 --- a/admin/index.php +++ b/admin/index.php @@ -153,7 +153,8 @@ if (!core_tables_exist()) { $strdatabasesetup = get_string('databasesetup'); $navigation = build_navigation(array(array('name'=>$strdatabasesetup, 'link'=>null, 'type'=>'misc'))); - print_header($strinstallation.' - Moodle '.$CFG->target_release, $strinstallation, $navigation, '', upgrade_get_javascript(), false, ' ', ' '); + upgrade_get_javascript(); + print_header($strinstallation.' - Moodle '.$CFG->target_release, $strinstallation, $navigation, '', '', false, ' ', ' '); if (!$DB->setup_is_unicodedb()) { if (!$DB->change_db_encoding()) { diff --git a/admin/report/unittest/test_tables.php b/admin/report/unittest/test_tables.php index 730a70871b2..71c5b32f34e 100644 --- a/admin/report/unittest/test_tables.php +++ b/admin/report/unittest/test_tables.php @@ -54,9 +54,6 @@ die;die;die; } } - echo upgrade_get_javascript(); - - /// return to original debugging level $DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml"); diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 27cef30285a..6bb12ca5dc5 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2072,7 +2072,7 @@ function print_header($title='', $heading='', $navigation='', $focus='', if ($meta) { throw new coding_exception('The $meta parameter to print_header is no longer supported. '. - 'You should be able to do weverything you want with $PAGE->requires and other such mechanisms.'); + 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.'); } if ($usexml) { throw new coding_exception('The $usexml parameter to print_header is no longer supported.'); diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 27afefac73c..e87779d09de 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -1040,4 +1040,20 @@ function focuscontrol(controlid) { if (control) { control.focus(); } -} \ No newline at end of file +} + +function scroll_to_end() { + window.scrollTo(0, 5000000); +} + +var scrolltoendtimeout; +function repeatedly_scroll_to_end() { + scrolltoendtimeout = setInterval(scroll_to_end, 50); +} + +function cancel_scroll_to_end() { + if (scrolltoendtimeout) { + clearTimeout(scrolltoendtimeout); + scrolltoendtimeout = null; + } +} diff --git a/lib/scroll_to_page_end.js b/lib/scroll_to_page_end.js deleted file mode 100644 index ebe831c172f..00000000000 --- a/lib/scroll_to_page_end.js +++ /dev/null @@ -1,17 +0,0 @@ -// keep the global scope clean -(function() { - - function scroll_to_page_end() { - window.scrollTo(0, 5000000); - }; - - // load should be a document event, but most browsers use window - if (window.addEventListener) { - window.addEventListener('load', scroll_to_page_end, false); - } else if (document.addEventListener) { - document.addEventListener('load', scroll_to_page_end, false); - } else if (window.attachEvent) { - window.attachEvent('onload', scroll_to_page_end); - } - -})(); diff --git a/lib/upgradelib.php b/lib/upgradelib.php index d14477d6dc7..6cf80286de0 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -751,9 +751,10 @@ function upgrade_started($preinstall=false) { if (!CLI_SCRIPT and !$PAGE->headerprinted) { $strupgrade = get_string('upgradingversion', 'admin'); + upgrade_get_javascript(); print_header($strupgrade.' - Moodle '.$CFG->target_release, $strupgrade, build_navigation(array(array('name' => $strupgrade, 'link' => null, 'type' => 'misc'))), '', - upgrade_get_javascript(), false, ' ', ' '); + '', false, ' ', ' '); } ignore_user_abort(true); @@ -895,8 +896,10 @@ function print_upgrade_part_end($plugin, $installation, $verbose) { * @global object */ function upgrade_get_javascript() { - global $CFG; - return ''; + global $PAGE; + $PAGE->requires->js('lib/javascript-static.js')->at_top_of_body(); + $PAGE->requires->js_function_call('repeatedly_scroll_to_end')->at_top_of_body(); + $PAGE->requires->js_function_call('cancel_scroll_to_end')->after_delay(1); }