From 7a56cc4738ab55cf61a3f0e4aa9ad0f7be6ed217 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 27 Apr 2020 15:12:16 +0200 Subject: [PATCH] _scripts/app.js: Adding collapse code --- _scripts/app.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/_scripts/app.js b/_scripts/app.js index 12d5ad0..50197d9 100644 --- a/_scripts/app.js +++ b/_scripts/app.js @@ -1,8 +1,22 @@ anchors.add(); -// adapted from https://stackoverflow.com/a/48078807/1217368 + $(document).ready(function() { + + $('.collapse-trigger').click(function() { + + var target_id = $(this).attr('data-target'); + + if (target_id) { + var target = $(document).find('#' + target_id); + + $(target).toggleClass('collapsed'); + } + }); + + + // adapted from https://stackoverflow.com/a/48078807/1217368 $('.highlight > pre').each(function(i) { if (!$(this).parent().hasClass('no-select-button')) {