From 62579c3d96da1f7df66df61bafd1fe6c16759813 Mon Sep 17 00:00:00 2001 From: rdrew Date: Thu, 18 Sep 2025 12:53:22 -0300 Subject: [PATCH] collapse test --- css/components/islandora_mods.css | 21 +++++++++++++++++++++ js/pwc_custom.js | 9 +++++++++ olivespwc.libraries.yml | 1 + 3 files changed, 31 insertions(+) create mode 100644 js/pwc_custom.js diff --git a/css/components/islandora_mods.css b/css/components/islandora_mods.css index 969a1b6..5efc0b5 100755 --- a/css/components/islandora_mods.css +++ b/css/components/islandora_mods.css @@ -48,3 +48,24 @@ text-decoration: underline; font-weight: bold; } +/*collapsable text on collections pages*/ +.text-container { + max-width: 600px; /* Adjust as needed */ +} + +.truncated-text { + max-height: 2.1em; /* Initial truncation height (~3 lines) */ + overflow: hidden; + transition: max-height 0.3s ease; +} + +.truncated-text.full { + max-height: none; /* Show full text */ +} + +.more-link { + color: #007bff; + cursor: pointer; + display: inline-block; + margin-top: 5px; +} diff --git a/js/pwc_custom.js b/js/pwc_custom.js new file mode 100644 index 0000000..8fd22b0 --- /dev/null +++ b/js/pwc_custom.js @@ -0,0 +1,9 @@ +document.querySelectorAll('.more-link').forEach(link => { + link.addEventListener('click', (e) => { + e.preventDefault(); + const container = link.previousElementSibling; + container.classList.toggle('full'); + link.textContent = container.classList.contains('full') ? 'Less' : 'More'; + link.setAttribute('aria-expanded', container.classList.contains('full')); + }); +}); diff --git a/olivespwc.libraries.yml b/olivespwc.libraries.yml index dbcca8c..e7eaca6 100755 --- a/olivespwc.libraries.yml +++ b/olivespwc.libraries.yml @@ -56,6 +56,7 @@ global-styling: js: js/checkbox.js: {} + js/pwc_custom.js: {} dependencies: - core/drupal