Skip to content
Merged
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
25 changes: 18 additions & 7 deletions htdocs/js/apps/PGProblemEditor/pgproblemeditor.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
(function () {
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') bsModal.hide();
});

const bsModal = new bootstrap.Modal(document.getElementById('render-modal'), { keyboard: true, show: false });

let busyIndicator = null;

const frame = document.getElementById('pg_editor_frame_id');
frame?.addEventListener('load', () => {
const removeBusyIndicator = () => {
if (busyIndicator) {
busyIndicator.remove();
busyIndicator = null;
}
};

const frame = document.getElementById('pg_editor_frame_id');
frame?.addEventListener('load', () => {
removeBusyIndicator();
if (frame.contentDocument.URL == 'about:blank') return;
const style = frame.contentDocument.createElement('style');
style.type = 'text/css';
Expand Down Expand Up @@ -42,8 +42,19 @@
busyIndicator = document.createElement('div');
busyIndicator.classList.add('page-loading-busy-indicator');
busyIndicator.innerHTML = '<div class="busy-text"><h2>Loading...</h2></div>' +
'<div><i class="fas fa-circle-notch fa-spin fa-3x"></i></div>';
'<div><i class="fas fa-circle-notch fa-spin fa-3x"></i></div>' +
'<div class="busy-text">Press escape to cancel</div>';
busyIndicator.tabIndex = -1;
document.body.appendChild(busyIndicator);
busyIndicator.focus();

// Allow the user to cancel loading of the iframe by pressing escape.
busyIndicator.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
removeBusyIndicator();
window.stop();
}
});
}
});

Expand Down
13 changes: 5 additions & 8 deletions htdocs/themes/math4/math4.scss
Original file line number Diff line number Diff line change
Expand Up @@ -771,24 +771,21 @@ input.changed[type=text] { /* orange */
height: 100%;
left: 0;
top: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1rem;
background: rgba(0, 0, 0, .5);
z-index: 105;

.busy-text {
position: relative;
color: white;
font-size: 1.4em;
top: calc(50% - 4em);
margin: auto;
width: 100%;
text-align: center;
}

i {
color: white;
position: absolute;
left: calc(50% - 30px);
top: calc(50% - 30px);
}
}

Expand Down