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
10 changes: 6 additions & 4 deletions app/javascript/src/utils/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@
* </div>
*/
$(() => {
$('body').on('click', '.accordion-controls', (e) => {
$('body').on('click', '.accordion-controls a', (e) => {
e.preventDefault();
const currentTarget = $(e.currentTarget);
const target = $(e.target);
const direction = target.attr('data-toggle-direction');
const parentTargetName = currentTarget.parent().attr('data-parent');
if (direction) {
// Selects all .panel elements where the parent is currentTarget.attr('data-parent') and
// after gets the immediately children whose class selector is panel-collapse
$(`#${currentTarget.attr('data-parent')} > .panel`).children('.panel-collapse').each((i, el) => {
const parentTarget = $(`#${parentTargetName}`).length ? $(`#${parentTargetName}`) : $(`.${parentTargetName}`);
$(parentTarget).find('.panel').find('.panel-collapse').each((i, el) => {
const panelCollapse = $(el);
// Expands or collapses the panel according to the
// direction passed (e.g. show --> expands, hide --> collapses)
if (direction === 'show') {
if (!panelCollapse.hasClass('in')) {
panelCollapse.prev().trigger('click');
if (!panelCollapse.find('.panel-body').attr('data-loaded') || !panelCollapse.hasClass('in')) {
panelCollapse.prev()[0].click();
}
} else {
panelCollapse.collapse(direction);
Expand Down
2 changes: 1 addition & 1 deletion app/views/org_admin/sections/_section.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
<% end %>
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions app/views/org_admin/sections/_section_group.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- TODO: Move this away from using ID attr -->
<div class="panel-group section-group"
<div class="panel-group section-group sections_accordion"
data-modifiable="<%= modifiable %>"
id="<%= panel_id %>"
role="tablist">
Expand All @@ -12,4 +12,4 @@
data_parent: panel_id,
draggable: draggable_for_section?(section) } %>
<% end%>
</div>
</div>