Skip to content
Snippets Groups Projects
Commit cdfa1408 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Animate on collapse and prevent collapsing on resize when already enlarged

parent 3b583c0f
No related branches found
No related tags found
1 merge request!51Display contact information on dataset page and use text-ellipsis for long description texts
...@@ -19,11 +19,12 @@ $(document).ready(function () { ...@@ -19,11 +19,12 @@ $(document).ready(function () {
} }
function adjustEllipsis() { function adjustEllipsis() {
$('.ellipsis-action').each(function () { $('.ellipsis-action:not(.full-text)').each(function () {
var ellipsisAction = $(this); var ellipsisAction = $(this);
var targetId = ellipsisAction.data('target'); var targetId = ellipsisAction.data('target');
var targetContent = $(targetId); var targetContent = $(targetId);
var maxContentHeight = ellipsisAction.data('max-height') || 150; var maxContentHeight = ellipsisAction.data('max-height') || 150;
var contentHeight = targetContent.height();
// Reset styles // Reset styles
targetContent.css({ targetContent.css({
...@@ -31,9 +32,6 @@ $(document).ready(function () { ...@@ -31,9 +32,6 @@ $(document).ready(function () {
'overflow-y': 'visible' 'overflow-y': 'visible'
}); });
// Calculate content height
var contentHeight = targetContent.height();
// Apply ellipsis functionality if necessary // Apply ellipsis functionality if necessary
if (contentHeight > maxContentHeight) { if (contentHeight > maxContentHeight) {
targetContent.css({ targetContent.css({
...@@ -46,9 +44,14 @@ $(document).ready(function () { ...@@ -46,9 +44,14 @@ $(document).ready(function () {
var readMoreLink = $('.readmore', ellipsisAction); var readMoreLink = $('.readmore', ellipsisAction);
var readLessLink = $('.readless', ellipsisAction); var readLessLink = $('.readless', ellipsisAction);
readMoreLink.show();
readLessLink.hide();
if (overlay) overlay.show();
readMoreLink.click(function (event) { readMoreLink.click(function (event) {
event.preventDefault(); event.preventDefault();
targetContent.css('max-height', 'none'); targetContent.css('max-height', 'none');
targetContent.addClass("full-text");
if (overlay) overlay.hide(); if (overlay) overlay.hide();
readMoreLink.hide(); readMoreLink.hide();
readLessLink.show(); readLessLink.show();
...@@ -57,9 +60,13 @@ $(document).ready(function () { ...@@ -57,9 +60,13 @@ $(document).ready(function () {
readLessLink.click(function (event) { readLessLink.click(function (event) {
event.preventDefault(); event.preventDefault();
targetContent.css('max-height', maxContentHeight + 'px'); targetContent.css('max-height', maxContentHeight + 'px');
targetContent.removeClass("full-text");
if (overlay) overlay.show(); if (overlay) overlay.show();
readMoreLink.show(); readMoreLink.show();
readLessLink.hide(); readLessLink.hide();
$('html, body').animate({
scrollTop: targetContent.offset().top
}, 50);
}); });
} else { } else {
ellipsisAction.hide(); ellipsisAction.hide();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment