NonInventPurchasingSystem/CPRNIMS.WebApps/wwwroot/JsFunctions/Utilities/ColumnStyle.js
2026-01-20 07:44:30 +08:00

20 lines
675 B
JavaScript

function renderExpandableItems(brSeparatedText, maxItems = 3) {
if (!brSeparatedText) return '';
const items = brSeparatedText.split('<br>');
const shortItems = items.slice(0, maxItems).join('<br>');
const fullItems = items.join('<br>');
if (items.length <= maxItems) {
return `<span class="item-display">${fullItems}</span>`;
}
return `
<span class="item-display">${shortItems}</span>
<button class="toggle-btn"
data-full-items="${encodeURIComponent(fullItems)}"
data-short-items="${encodeURIComponent(shortItems)}"
data-expanded="false">...see more</button>
`;
}