Enhance loading indicators for question fragment during HTMX requests; ensure overview tile text color remains unchanged for flagged questions
This commit is contained in:
@@ -76,55 +76,55 @@
|
||||
}catch(e){ console && console.error && console.error(e); }
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
<script>
|
||||
// Show a blur + spinner on the question fragment while HTMX loads it
|
||||
(function(){
|
||||
function showLoading(){
|
||||
try{
|
||||
const frag = document.getElementById('question-fragment');
|
||||
if(!frag) return;
|
||||
frag.classList.add('loading');
|
||||
if(!frag.querySelector('.loading-spinner')){
|
||||
const s = document.createElement('div');
|
||||
s.className = 'loading-spinner';
|
||||
s.setAttribute('aria-hidden','true');
|
||||
frag.appendChild(s);
|
||||
}
|
||||
}catch(e){console && console.error && console.error(e);}
|
||||
}
|
||||
(function(){
|
||||
function showLoading(){
|
||||
try{
|
||||
const frag = document.getElementById('question-fragment');
|
||||
if(!frag) return;
|
||||
frag.classList.add('loading');
|
||||
if(!frag.querySelector('.loading-spinner')){
|
||||
const s = document.createElement('div');
|
||||
s.className = 'loading-spinner';
|
||||
s.setAttribute('aria-hidden','true');
|
||||
frag.appendChild(s);
|
||||
}
|
||||
}catch(e){console && console.error && console.error(e);}
|
||||
}
|
||||
|
||||
function hideLoading(){
|
||||
try{
|
||||
const frag = document.getElementById('question-fragment');
|
||||
if(!frag) return;
|
||||
frag.classList.remove('loading');
|
||||
const s = frag.querySelector('.loading-spinner'); if(s) s.remove();
|
||||
}catch(e){console && console.error && console.error(e);}
|
||||
}
|
||||
function hideLoading(){
|
||||
try{
|
||||
const frag = document.getElementById('question-fragment');
|
||||
if(!frag) return;
|
||||
frag.classList.remove('loading');
|
||||
const s = frag.querySelector('.loading-spinner'); if(s) s.remove();
|
||||
}catch(e){console && console.error && console.error(e);}
|
||||
}
|
||||
|
||||
document.body.addEventListener('htmx:beforeRequest', function(evt){
|
||||
try{
|
||||
const target = (evt.detail && (evt.detail.target || evt.detail.elt)) || evt.target;
|
||||
document.body.addEventListener('htmx:beforeRequest', function(evt){
|
||||
try{
|
||||
const target = (evt.detail && (evt.detail.target || evt.detail.elt)) || evt.target;
|
||||
// if the request targets the question fragment, show loading
|
||||
if(target && (target.id === 'question-fragment' || (target.closest && target.closest('#question-fragment')))){
|
||||
showLoading();
|
||||
}
|
||||
}catch(e){/* ignore */}
|
||||
});
|
||||
if(target && (target.id === 'question-fragment' || (target.closest && target.closest('#question-fragment')))){
|
||||
showLoading();
|
||||
}
|
||||
}catch(e){/* ignore */}
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', function(evt){
|
||||
try{
|
||||
const target = (evt.detail && (evt.detail.target || evt.detail.elt)) || evt.target;
|
||||
if(target && (target.id === 'question-fragment' || (target.closest && target.closest('#question-fragment')))){
|
||||
hideLoading();
|
||||
}
|
||||
}catch(e){}
|
||||
});
|
||||
document.body.addEventListener('htmx:afterSwap', function(evt){
|
||||
try{
|
||||
const target = (evt.detail && (evt.detail.target || evt.detail.elt)) || evt.target;
|
||||
if(target && (target.id === 'question-fragment' || (target.closest && target.closest('#question-fragment')))){
|
||||
hideLoading();
|
||||
}
|
||||
}catch(e){}
|
||||
});
|
||||
|
||||
// also hide after settle to be safe
|
||||
document.body.addEventListener('htmx:afterSettle', function(evt){ hideLoading(); });
|
||||
})();
|
||||
</script>
|
||||
document.body.addEventListener('htmx:afterSettle', function(evt){ hideLoading(); });
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
// Also update after HTMX settle to ensure DOM changes are applied
|
||||
document.body.addEventListener('htmx:afterSettle', function(){
|
||||
|
||||
@@ -133,6 +133,15 @@
|
||||
|
||||
/* Flagged questions show only the flag icon; do not change border color */
|
||||
|
||||
/* Ensure global `.flagged` rules don't change the overview tile text colour. */
|
||||
.overview-question-btn.flagged {
|
||||
color: inherit !important;
|
||||
}
|
||||
.overview-question-btn.flagged .qn-num,
|
||||
.overview-question-btn.flagged .qn-ans {
|
||||
color: inherit !important;
|
||||
}
|
||||
|
||||
.overview-question-btn .question-flag {
|
||||
margin-left: auto;
|
||||
font-size: 0.95rem;
|
||||
|
||||
Reference in New Issue
Block a user