2017-06-21 03:49:38 -04:00
|
|
|
function expandSectionParent($section, $content) {
|
|
|
|
$section.addClass('expanded');
|
|
|
|
$content.off('animationend.expandSectionParent');
|
|
|
|
}
|
|
|
|
|
2017-06-07 04:11:44 -04:00
|
|
|
function expandSection($section) {
|
2017-06-22 10:32:04 -04:00
|
|
|
$section.find('.js-settings-toggle').text('Collapse');
|
2017-06-21 03:49:38 -04:00
|
|
|
|
|
|
|
const $content = $section.find('.settings-content');
|
|
|
|
$content.addClass('expanded').off('scroll.expandSection').scrollTop(0);
|
|
|
|
|
|
|
|
if ($content.hasClass('no-animate')) {
|
|
|
|
expandSectionParent($section, $content);
|
|
|
|
} else {
|
|
|
|
$content.on('animationend.expandSectionParent', () => expandSectionParent($section, $content));
|
|
|
|
}
|
2017-06-07 04:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function closeSection($section) {
|
|
|
|
$section.find('.js-settings-toggle').text('Expand');
|
2017-06-21 03:49:38 -04:00
|
|
|
|
|
|
|
const $content = $section.find('.settings-content');
|
|
|
|
$content.removeClass('expanded').on('scroll.expandSection', () => expandSection($section));
|
|
|
|
|
|
|
|
$section.removeClass('expanded');
|
2017-06-07 04:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleSection($section) {
|
|
|
|
const $content = $section.find('.settings-content');
|
|
|
|
$content.removeClass('no-animate');
|
|
|
|
if ($content.hasClass('expanded')) {
|
|
|
|
closeSection($section);
|
|
|
|
} else {
|
|
|
|
expandSection($section);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function initSettingsPanels() {
|
|
|
|
$('.settings').each((i, elm) => {
|
|
|
|
const $section = $(elm);
|
2017-06-21 03:49:38 -04:00
|
|
|
$section.on('click.toggleSection', '.js-settings-toggle', () => toggleSection($section));
|
|
|
|
$section.find('.settings-content:not(.expanded)').on('scroll.expandSection', () => expandSection($section));
|
2017-06-07 04:11:44 -04:00
|
|
|
});
|
|
|
|
}
|