JS: add events 'cell:open' & 'cell:close' (#53780)

This commit is contained in:
Thomas Jund 2021-05-05 14:54:03 +02:00
parent 7f80d29f0e
commit 44ee86eded
1 changed files with 15 additions and 4 deletions

View File

@ -347,12 +347,23 @@ $(function() {
});
$('div.cell').each(function(i, x) {
compute_max_height($(this));
if (window.location.hash == '#' + $(this).attr('id')) {
$(this).addClass('toggled');
const $cell = $(this);
compute_max_height($cell);
if (window.location.hash == '#' + $cell.attr('id')) {
$cell.addClass('toggled');
} else {
$(this).addClass('untoggled');
$cell.addClass('untoggled');
}
const $animated = $cell.find('h3 + div');
$animated.on('transitionend', function(el){
if ($cell.is(".toggled")) {
$cell.trigger("cell:open");
}
if ($cell.is(".untoggled")) {
$cell.trigger("cell:close");
}
})
});
function show_asset($elem) {