Skip to content

Commit

Permalink
fix: show more on comment length
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Dec 30, 2024
1 parent 21366e8 commit 88bf752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const card = (() => {
</div>
<hr class="text-${text} my-1">
<p class="text-${text} my-1 mx-0 p-0" style="white-space: pre-wrap !important; font-size: 0.95rem;" ${moreThanMaxLength ? `data-comment="${util.base64Encode(original)}"` : ''} id="content-${comment.uuid}">${moreThanMaxLength ? (original.slice(0, maxCommentLength) + '...') : original}</p>
${moreThanMaxLength ? `<p class="mb-2 mt-0 mx-0 p-0"><a class="text-${text}" role="button" style="font-size: 0.85rem;" data-show="false" onclick="comment.showMore(this, '${comment.uuid}')">Selengkapnya</a></p>` : ''}`;
${moreThanMaxLength ? `<p class="mb-2 mt-0 mx-0 p-0"><a class="text-${text}" role="button" style="font-size: 0.85rem; display: block;" data-show="false" onclick="comment.showMore(this, '${comment.uuid}')">Selengkapnya</a></p>` : ''}`;
};

const renderContent = (comment, is_parent) => {
Expand Down
11 changes: 10 additions & 1 deletion js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,18 @@ export const comment = (() => {
const original = card.convertMarkdownToHTML(util.escapeHtml(form.value));
const content = document.getElementById(`content-${id}`);

content.innerHTML = show && show.getAttribute('data-show') == 'false' ? original.slice(0, card.maxCommentLength) + '...' : original;
if (original.length > card.maxCommentLength) {
content.innerHTML = show?.getAttribute('data-show') === 'false' ? original.slice(0, card.maxCommentLength) + '...' : original;
content.setAttribute('data-comment', util.base64Encode(original));
if (show?.style.display === 'none') {
show.style.display = 'block';
}
} else {
content.innerHTML = original;
content.removeAttribute('data-comment');
if (show?.style.display === 'block') {
show.style.display = 'none';
}
}

if (presence) {
Expand Down

0 comments on commit 88bf752

Please sign in to comment.