Skip to content

Commit 63b307d

Browse files
committed
Mathjax and Moodle 5 compatibility changes
update version of JS call
1 parent 969f791 commit 63b307d

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
$stringman = get_string_manager();
466466
$strings = $stringman->load_component_strings('pdfannotator', 'en'); // Method gets the strings of the language files.
467467
$PAGE->requires->strings_for_js(array_keys($strings), 'pdfannotator'); // Method to use the language-strings in javascript.
468-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00002"));
468+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00007"));
469469
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/statistic.js?ver=0004"));
470470
$myrenderer = $PAGE->get_renderer('mod_pdfannotator');
471471
$capabilities = new stdClass();

locallib.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
6666
// Load and execute the javascript files.
6767
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
6868
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
69-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00039"));
70-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00006"));
69+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00046"));
70+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00007"));
7171

7272
// Pass parameters from PHP to JavaScript.
7373

@@ -328,7 +328,7 @@ function pdfannotator_data_preprocessing($context, $textarea, $draftitemid = 0)
328328
* Same function as core, however we need to add files into the existing draft area!
329329
* Copied from hsuforum.
330330
*/
331-
function pdfannotator_file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) {
331+
function pdfannotator_file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, ?array $options=null, ?string $text=null) {
332332
global $CFG, $USER, $CFG, $DB;
333333

334334
$options = (array)$options;
@@ -869,7 +869,7 @@ function pdfannotator_set_mainfile($data) {
869869
}
870870
}
871871

872-
function pdfannotator_render_listitem_actions(array $actions = null) {
872+
function pdfannotator_render_listitem_actions(?array $actions = null) {
873873
$menu = new action_menu();
874874
$menu->attributes['class'] .= ' course-item-actions item-actions';
875875
$hasitems = false;
@@ -985,7 +985,7 @@ function pdfannotator_prepare_overviewpage($cmid, $myrenderer, $taburl, $action,
985985
$PAGE->requires->strings_for_js(array_keys($strings), 'pdfannotator'); // Method to use the language-strings in javascript.
986986
// 1.3 Add the javascript file that determines the dynamic behaviour of the page.
987987
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00002"));
988-
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/overview.js?ver=00002"));
988+
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/overview.js?ver=00003"));
989989

990990
// 1.4 Check user capabilities to view the different categories.
991991
// The argument 'false' disregards administrator's magical 'doanything' power.

shared/locallib.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ function renderMathJax(node) {
8787
var counter = 0;
8888
let mathjax = function (node) {
8989
if (typeof (MathJax) !== "undefined") {
90-
MathJax.Hub.Queue(['Typeset', MathJax.Hub, node]);
90+
if (MathJax.Hub !== undefined) {
91+
MathJax.Hub.Queue(['Typeset', MathJax.Hub, node]);
92+
}
9193
} else if (counter < 30) {
9294
counter++;
9395
setTimeout(mathjax, 100);

shared/overview.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ function startOverview(Y, __annotatorid, __cmid, __capabilities, __action) { //
482482
var counter = 0;
483483
let mathjax = function () {
484484
if (typeof (MathJax) !== "undefined") {
485-
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
485+
//MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
486+
if (MathJax.Hub !== undefined) {
487+
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
488+
}
486489
} else if (counter < 10) {
487490
counter++;
488491
setTimeout(mathjax, 200);

0 commit comments

Comments
 (0)