jquery-collapser icon indicating copy to clipboard operation
jquery-collapser copied to clipboard

Line count wrong when switching to HTML

Open seanhak opened this issue 10 years ago • 1 comments

Hey, great job, very useful plugin.

I did some changes to your codebase to allow the truncated content to maintain html-tags. This is useful if you want to keep bold and italic text, or in my case paragraphs. I changed this by deleting this line of code: eWrap.html( eWrap.text() ); however now the lines are not calculated right, and often ends with decimals. Any ideas? My guess is that jQuery height calculation is a bit wonky when calculating padding etc.

I also added following code to hide button and cancel hiding:

if (s.remaining['lines'] < (s.o.truncate - 1)) {
 if ($.isFunction(s.o.controlBtn)) {
  s.o.controlBtn.call(s.e).hide();
 }                      
return false;
}

It would be nice if this was part of the core features.

Cheers

seanhak avatar Feb 15 '15 23:02 seanhak

Sup Seanhak, I was having the same issues you're describing. I solved em by using

var toReplace = s.remaining[s.mode].toFixed() + ( s.remaining[s.mode] == 1 ? ' ' + plural[s.mode][0] : ' ' + plural[s.mode][1] );

at line 334ish. So I added .toFixed() to the remaining s.mode.

This works pretty well so far.

bhalial avatar Jul 03 '15 10:07 bhalial