forked from openwebwork/pg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
986 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,8 @@ | |
align-self: center; | ||
} | ||
} | ||
|
||
.dd-feedback-container { | ||
display: flex; | ||
justify-content: start; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(() => { | ||
const initializeFeedback = (feedbackBtn) => { | ||
if (feedbackBtn.dataset.popoverInitialized) return; | ||
feedbackBtn.dataset.popoverInitialized = 'true'; | ||
|
||
new bootstrap.Popover(feedbackBtn, { | ||
sanitizeFn(content) { | ||
return content; | ||
} | ||
}); | ||
|
||
// Render MathJax previews. | ||
if (window.MathJax) { | ||
feedbackBtn.addEventListener('show.bs.popover', () => { | ||
MathJax.startup.promise = MathJax.startup.promise.then(() => MathJax.typesetPromise(['.popover-body'])); | ||
}); | ||
} | ||
|
||
// Execute javascript in the answer preview. | ||
feedbackBtn.addEventListener('shown.bs.popover', () => { | ||
const bsPopover = bootstrap.Popover.getInstance(feedbackBtn); | ||
bsPopover.tip?.querySelectorAll('script').forEach((origScript) => { | ||
const newScript = document.createElement('script'); | ||
Array.from(origScript.attributes).forEach((attr) => newScript.setAttribute(attr.name, attr.value)); | ||
newScript.appendChild(document.createTextNode(origScript.innerHTML)); | ||
origScript.parentNode.replaceChild(newScript, origScript); | ||
}); | ||
}); | ||
}; | ||
|
||
// Setup feedback popovers already on the page. | ||
document.querySelectorAll('.ww-feedback-btn').forEach(initializeFeedback); | ||
|
||
// Deal with feedback popovers that are added to the page later. | ||
const observer = new MutationObserver((mutationsList) => { | ||
mutationsList.forEach((mutation) => { | ||
mutation.addedNodes.forEach((node) => { | ||
if (node instanceof Element) { | ||
if (node.classList.contains('ww-feedback-btn')) initializeFeedback(node.firstElementChild); | ||
else node.querySelectorAll('.ww-feedback-btn').forEach(initializeFeedback); | ||
} | ||
}); | ||
}); | ||
}); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
|
||
// Stop the mutation observer when the window is closed. | ||
window.addEventListener('unload', () => observer.disconnect()); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.