|
/*Read More text on a table cell */ |
|
$(document).ready(function(){ |
|
|
|
var maxLength = 15; // give character length here |
|
var colNames = ['title','citation', 'summary']; // give your column key here |
|
var readMoreText = "read more..."; // give read more text here |
|
var readLessText = "read less..."; //give read less text here |
|
|
|
function limitChar(){ |
|
for(i = 0 ; i<colNames.length; i++){ |
|
$(".ninja_clmn_nm_"+colNames[i]).each(function(){ |
|
var myStr = $(this).text(); |
|
if($.trim(myStr).length > maxLength){ |
|
var newStr = myStr.substring(0, maxLength); |
|
var removedStr = myStr.substring(maxLength, $.trim(myStr).length); |
|
removedStr = removedStr.replace(readMoreText,''); |
|
removedStr = removedStr.replace(readLessText,''); |
|
$(this).empty().html(newStr); |
|
$(this).append('<span class="more-text">' + removedStr + '</span>'); |
|
$(this).append(' <span class="read-more read-less-more" style="color:blue; cursor:pointer">'+readMoreText+'</span>'); |
|
$(this).append(' <span class="read-less read-less-more" style="color:blue; cursor:pointer">'+readLessText+'</span>'); |
|
$(this).find('.read-less').hide(); |
|
$(this).find('.more-text').hide(); |
|
} |
|
|
|
}); |
|
|
|
$(".read-more").click(function(){ |
|
$(this).siblings(".more-text").show(); |
|
$(this).siblings(".read-less").show(); |
|
$(this).hide(); |
|
}); |
|
|
|
$(".read-less").click(function(){ |
|
$(this).siblings(".more-text").hide(); |
|
$(this).siblings(".read-more").show(); |
|
$(this).hide(); |
|
}); |
|
} |
|
} |
|
|
|
limitChar(); |
|
|
|
$table.on('after.ft.paging', function () { |
|
limitChar(); |
|
}); |
|
|
|
$table.on("after.ft.filtering", function () { |
|
limitChar(); |
|
}); |
|
|
|
}); |