47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
function sellectTableRows(table, checkBoxId) {
|
|
$(table).on('change', '.selected-Item-checkbox', function () {
|
|
var row = $(this).closest('tr');
|
|
if ($(this).prop('checked')) {
|
|
row.addClass('selected-row');
|
|
} else {
|
|
row.removeClass('selected-row');
|
|
}
|
|
updateTotalSelectedCount();
|
|
});
|
|
$(checkBoxId).on('change', function () {
|
|
var isChecked = $(this).prop('checked');
|
|
|
|
$('.selected-Item-checkbox').prop('checked', isChecked);
|
|
if (isChecked) {
|
|
$(table + ' tbody tr').addClass('selected-row');
|
|
} else {
|
|
$(table + ' tbody tr').removeClass('selected-row');
|
|
}
|
|
|
|
updateTotalSelectedCount();
|
|
});
|
|
}
|
|
function updateTotalSelectedCount() {
|
|
var totalSelected = $('.selected-Item-checkbox:checked').length;
|
|
totalSelectedLabel.text(totalSelected);
|
|
}
|
|
$(document).on('click', '.toggle-btn', function () {
|
|
var $button = $(this);
|
|
var $span = $button.prev('.item-display');
|
|
var isExpanded = $button.data('expanded');
|
|
|
|
if (!isExpanded) {
|
|
// Show the full content
|
|
var fullItems = decodeURIComponent($button.attr('data-full-items'));
|
|
$span.html(fullItems);
|
|
$button.text('...see less');
|
|
} else {
|
|
// Show the short content
|
|
var shortItems = decodeURIComponent($button.attr('data-short-items'));
|
|
$span.html(shortItems);
|
|
$button.text('...see more');
|
|
}
|
|
|
|
// Toggle the expanded state
|
|
$button.data('expanded', !isExpanded);
|
|
}); |