diff --git a/htdocs/js/DragNDrop/dragndrop.js b/htdocs/js/DragNDrop/dragndrop.js index dc91f45b57..f4f2edc9a4 100644 --- a/htdocs/js/DragNDrop/dragndrop.js +++ b/htdocs/js/DragNDrop/dragndrop.js @@ -382,11 +382,7 @@ else bucketPool.bucketContainer.append(this.el); // Typeset any math content that may be in the added html. - if (window.MathJax) { - window.MathJax.startup.promise = window.MathJax.startup.promise.then(() => - window.MathJax.typesetPromise([this.el]) - ); - } + if (window.MathJax) window.MathJax.typesetPromise?.([this.el]); const options = { group: { name: bucketPool.answerName }, diff --git a/htdocs/js/DropDown/dropdown.js b/htdocs/js/DropDown/dropdown.js index 170a96c837..b85b48ccac 100644 --- a/htdocs/js/DropDown/dropdown.js +++ b/htdocs/js/DropDown/dropdown.js @@ -28,8 +28,7 @@ dropdownBtn.textContent = option.dataset.content; dropdownBtn.focus(); - if (window.MathJax) - MathJax.startup.promise = MathJax.startup.promise.then(() => MathJax.typesetPromise([dropdownBtn])); + if (window.MathJax) MathJax.typesetPromise?.([dropdownBtn]); // If any feedback popovers are open, then update their positions. for (const popover of document.querySelectorAll('.ww-feedback-btn')) { diff --git a/htdocs/js/Essay/essay.js b/htdocs/js/Essay/essay.js index 3c7a747e7c..1ad3d93b54 100644 --- a/htdocs/js/Essay/essay.js +++ b/htdocs/js/Essay/essay.js @@ -49,11 +49,9 @@ ); if (window.MathJax) { button.addEventListener( - 'show.bs.popover', + 'inserted.bs.popover', () => { - MathJax.startup.promise = MathJax.startup.promise.then(() => - MathJax.typesetPromise(['.popover-body']) - ); + MathJax.typesetPromise?.([popover.tip]); }, { once: true } ); diff --git a/htdocs/js/Feedback/feedback.js b/htdocs/js/Feedback/feedback.js index 731dcb8c55..b4de5d39f7 100644 --- a/htdocs/js/Feedback/feedback.js +++ b/htdocs/js/Feedback/feedback.js @@ -11,16 +11,10 @@ }); feedbackPopovers.push(feedbackPopover); - // Render MathJax previews. - if (window.MathJax) { - feedbackBtn.addEventListener('show.bs.popover', () => { - MathJax.startup.promise = MathJax.startup.promise.then(() => - MathJax.typesetPromise(['.popover-body']).then(() => feedbackPopover.update()) - ); - }); - } + feedbackBtn.addEventListener('inserted.bs.popover', () => { + // Render MathJax previews. + if (window.MathJax) MathJax.typesetPromise?.([feedbackPopover.tip]).then(() => feedbackPopover.update()); - feedbackBtn.addEventListener('shown.bs.popover', () => { // Execute javascript in the answer preview. feedbackPopover.tip?.querySelectorAll('script').forEach((origScript) => { const newScript = document.createElement('script'); diff --git a/htdocs/js/GraphTool/graphtool.js b/htdocs/js/GraphTool/graphtool.js index bb539ed0b9..db0ef2f5e2 100644 --- a/htdocs/js/GraphTool/graphtool.js +++ b/htdocs/js/GraphTool/graphtool.js @@ -702,11 +702,7 @@ window.graphTool = (containerId, options) => { newContent.classList.add('gt-message-content'); setTimeout(() => newContent.classList.add('gt-message-content', 'gt-message-fade')); - if (window.MathJax) { - MathJax.startup.promise = MathJax.startup.promise.then(() => - MathJax.typesetPromise([newContent]) - ); - } + if (window.MathJax) MathJax.typesetPromise?.([newContent]); } resolve(); diff --git a/htdocs/js/Knowls/knowl.js b/htdocs/js/Knowls/knowl.js index 78a933827f..0894f988f9 100644 --- a/htdocs/js/Knowls/knowl.js +++ b/htdocs/js/Knowls/knowl.js @@ -89,9 +89,7 @@ setInnerHTML(knowlBody, knowl.dataset.knowlContents); // If we are using MathJax, then render math content. - if (window.MathJax) { - MathJax.startup.promise = MathJax.startup.promise.then(() => MathJax.typesetPromise([knowlBody])); - } + if (window.MathJax) MathJax.typesetPromise?.([knowlBody]); } else if (knowl.dataset.knowlUrl) { // Retrieve url content. fetch(knowl.dataset.knowlUrl) @@ -104,11 +102,7 @@ setInnerHTML(knowlBody, data); } // If we are using MathJax, then render math content. - if (window.MathJax) { - MathJax.startup.promise = MathJax.startup.promise.then(() => - MathJax.typesetPromise([knowlBody]) - ); - } + if (window.MathJax) MathJax.typesetPromise?.([knowlBody]); }) .catch((err) => { knowlBody.textContent = `ERROR: ${err}`; diff --git a/htdocs/js/MathView/mathview.js b/htdocs/js/MathView/mathview.js index 1162363876..f193f2d6ac 100644 --- a/htdocs/js/MathView/mathview.js +++ b/htdocs/js/MathView/mathview.js @@ -212,7 +212,10 @@ this.button.addEventListener('show.bs.popover', () => { this.regenPreview(); - MathJax.startup.promise = MathJax.startup.promise.then(() => MathJax.typesetPromise(['.popover'])); + }); + + this.button.addEventListener('inserted.bs.popover', () => { + MathJax.typesetPromise?.([this.popover.tip]); }); // Refresh math in the popover when there is a keyup in the input. @@ -283,7 +286,7 @@ if (this.renderingMode === 'LATEX') this.mviewer.textContent = `\\(${text}\\)`; else this.mviewer.textContent = `\`${text}\``; - MathJax.startup.promise = MathJax.startup.promise.then(() => MathJax.typesetPromise([this.mviewer])); + MathJax.typesetPromise?.([this.mviewer]); } // Create a category from the locale js. Each category is implemented using bootstraps tab feature. The