Skip to content

Instantly share code, notes, and snippets.

@amitguptagwl
Created June 27, 2018 04:59
Show Gist options
  • Save amitguptagwl/336a37701346d0dce1c3e325a77fa594 to your computer and use it in GitHub Desktop.
Save amitguptagwl/336a37701346d0dce1c3e325a77fa594 to your computer and use it in GitHub Desktop.
api.checklist.com
//Following snippet make the nested tasks collapsible
$("ol.task li").each(function(){
var subtasks = $(this).find(".subtasks ol li");
if(subtasks.length !== 0){
$( $( $(this).children()[0] ).children()[0] ).prepend('<span class="expandable">-</span>');
}
});
$(".expandable").click(function(e){
var subtasks = $(this).parent().parent().next();
if(subtasks.hasClass("collapsed")){
subtasks.removeClass("collapsed");
subtasks.addClass("expanded");
$(this).text("-");
subtasks.show(500);
}else{
subtasks.removeClass("expanded");
subtasks.addClass("collapsed");
$(this).text("+");
subtasks.hide(500);
}
e.preventDefault();
e.stopPropagation();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment