Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions htdocs/js/DragNDrop/dragndrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
3 changes: 1 addition & 2 deletions htdocs/js/DropDown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
6 changes: 2 additions & 4 deletions htdocs/js/Essay/essay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);
Expand Down
12 changes: 3 additions & 9 deletions htdocs/js/Feedback/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 1 addition & 5 deletions htdocs/js/GraphTool/graphtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 2 additions & 8 deletions htdocs/js/Knowls/knowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}`;
Expand Down
7 changes: 5 additions & 2 deletions htdocs/js/MathView/mathview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading