instack-undercloud/doc/source/_custom/expandable.js
Jaromir Coufal 817a6e58e8 Allow user to display/hide admonitions
Change-Id: I4ead7e3d7505b223737e63bdcefe2dfc2310b657
2015-04-27 11:59:35 +02:00

33 lines
903 B
JavaScript

$(document).ready(function() {
// for each trigger
$('.trigger').each(function() {
// check if cookie has value on true
if ($.cookie($(this).parent().prop('id')) == "true") {
// add displayed class and show the content
$(this).parent().addClass("displayed");
$(this).next('.content').show();
} else {
// remove displayed class and hide the content
$(this).parent().removeClass("displayed");
$(this).next('.content').hide();
}
});
// if user clicked trigger element
$('.trigger').click(function() {
// toggle parent's class and animate the content
$(this).parent().toggleClass('displayed');
$(this).next('.content').slideToggle("fast");
// save the state to cookies
var parent_id =
$.cookie($(this).parent().prop('id'),
$(this).parent().hasClass('displayed'),
{ path: '/' });
});
});