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

34 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-03-30 17:00:35 +02:00
$(document).on('turbolinks:load', init_default_data_block);
function init_default_data_block() {
2017-04-04 16:15:33 +02:00
$('.default_data_block #dossier .body').toggle();
$('.default_data_block #dossier .carret-right').toggle();
$('.default_data_block #dossier .carret-down').toggle();
2017-04-04 16:15:33 +02:00
$('.default_data_block .title').click(function () {
toggle_default_data_bloc(this, 400);
});
2017-04-04 16:15:33 +02:00
$('.new-action').click(function () {
var messages_block = $(this).parents().closest('.default_data_block').find('.title')
toggle_default_data_bloc(messages_block, 400);
});
2017-04-04 16:15:33 +02:00
$('.default_data_block.default_visible').each(function() {
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();
$(".commentaires").animate({ scrollTop: $(this).height() }, "slow");
}
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();
}
}