fix: conditionally hide sections in edit mode only
Wrapped the logic to hide sections in an edit mode check, ensuring it only runs when the page is in edit mode. This prevents unintended hiding of sections during normal view, improving the user experience.
This commit is contained in:
parent
a1185aba77
commit
8c1e8c49eb
1 changed files with 15 additions and 11 deletions
26
script.js
26
script.js
|
@ -212,18 +212,22 @@
|
|||
);
|
||||
});
|
||||
|
||||
var sections = $('.course-section');
|
||||
var found = false;
|
||||
const editMode = $(".inplaceeditable").length > 0;
|
||||
|
||||
sections.each(function (index) {
|
||||
if (!found && $(this).find('script[data-activity-id]').length > 0) {
|
||||
// Set found to true when the first matching section is found
|
||||
found = true;
|
||||
} else if (found) {
|
||||
// Hide all .section elements after the found one
|
||||
$(this).css('visibility', 'hidden');
|
||||
}
|
||||
});
|
||||
if (editMode) {
|
||||
var sections = $('.course-section');
|
||||
var found = false;
|
||||
|
||||
sections.each(function (index) {
|
||||
if (!found && $(this).find('script[data-activity-id]').length > 0) {
|
||||
// Set found to true when the first matching section is found
|
||||
found = true;
|
||||
} else if (found) {
|
||||
// Hide all .section elements after the found one
|
||||
$(this).css('visibility', 'hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
Loading…
Reference in a new issue