Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$(document).ready(function () {
function adjustEllipsis() {
$('.ellipsis-action').each(function () {
var ellipsisAction = $(this);
var targetId = ellipsisAction.data('target');
var targetContent = $(targetId);
var maxContentHeight = ellipsisAction.data('max-height') || 150;
var overlay = $('.ellipsis-overlay', ellipsisAction);
var readMoreLink = $('.readmore', ellipsisAction);
var readLessLink = $('.readless', ellipsisAction);
// Reset styles to calculate content height
targetContent.css({
'max-height': 'none',
'overflow-y': 'visible'
});
var contentHeight = targetContent.height();
// Apply ellipsis functionality if necessary
if (contentHeight > maxContentHeight) {
ellipsisAction.show();
if (targetContent.hasClass("full-text")) {
toggleEllipsisActions(false);
} else {
targetContent.css({
'max-height': maxContentHeight + 'px',
'overflow-y': 'hidden'
});
toggleEllipsisActions(true);
if (overlay) overlay.show();
}
} else {
ellipsisAction.hide();
}
function toggleEllipsisActions(showReadMore) {
readMoreLink.toggle(showReadMore);
readLessLink.toggle(!showReadMore);
}
readMoreLink.off('click').on('click', function (event) {
event.preventDefault();
targetContent.css({
'max-height': 'none',
'overflow-y': 'visible'
});
targetContent.addClass("full-text");
if (overlay) overlay.hide();
toggleEllipsisActions(false);
});
readLessLink.off('click').on('click', function (event) {
event.preventDefault();
targetContent.css({
'max-height': maxContentHeight + 'px',
'overflow-y': 'hidden'
});
targetContent.removeClass("full-text");
if (overlay) overlay.show();
toggleEllipsisActions(true);
$('html, body').animate({
scrollTop: targetContent.offset().top
}, 50);
});
});
}
// Call the function on page load
adjustEllipsis();
// Add an event listener for window resize
$(window).on('resize', function () {
// Call the adjustEllipsis function when window is resized
adjustEllipsis();
});
});