demarches-normaliennes/app/assets/javascripts/old_design/default_data_block.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-10-02 16:59:30 +02:00
/* globals $ */
2020-05-07 16:31:36 +02:00
$(document).on('DOMContentLoaded', init_default_data_block);
function init_default_data_block() {
$('.default-data-block #dossier .body').toggle();
$('.default-data-block #dossier .carret-right').toggle();
$('.default-data-block #dossier .carret-down').toggle();
2020-04-30 15:42:29 +02:00
$('.default-data-block .title').click(function () {
2017-04-04 16:15:33 +02:00
toggle_default_data_bloc(this, 400);
});
2020-04-30 15:42:29 +02:00
$('.new-action').click(function () {
2018-10-02 16:59:30 +02:00
var messages_block = $(this)
.parents()
.closest('.default-data-block')
.find('.title');
2017-04-04 16:15:33 +02:00
toggle_default_data_bloc(messages_block, 400);
});
2020-04-30 15:42:29 +02:00
$('.default-data-block.default_visible').each(function () {
2017-04-04 16:15:33 +02:00
toggle_default_data_bloc($(this).find('.title'), 0);
});
2017-04-04 16:15:33 +02:00
function toggle_default_data_bloc(element, duration) {
var block = $(element).parents('.show-block');
if (block.attr('id') == 'messages') {
block.children('.last-commentaire').toggle();
2018-10-02 16:59:30 +02:00
$('.commentaires').animate({ scrollTop: $(this).height() }, 'slow');
2017-04-04 16:15:33 +02:00
}
2017-04-04 16:15:33 +02:00
block.children('.body').slideToggle(duration);
2017-04-04 16:15:33 +02:00
block.find('.carret-right').toggle();
block.find('.carret-down').toggle();
}
}