vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=201747

Trimming thread title at end of a cell rather than at specific number of characters
by sparklywater
14 Jan 2009 14:37

I am currently using a function which trims the thread title automatically after a specified number of characters in the title. Since the thread-title is displayed in a table-cell with a percentage width, the cell automatically expands depending on the size of the screen. I would therefore like to use a function that will trim the thread-title whenever the title reaches the end of the cell, rather than at a fixed position after a certain number of characters. How can I do this?

Here is the code to the current function:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Lynne 14 Jan 2009 14:42

You can't do that. Every browser renders a page differently and the table cell width is very often dependent and other table cell widths also. There is no way to figure out what the width of the cell is going to be prior to it being rendered. And even then, sometimes you see it expand/contract right before your eyes.

Bellardia 14 Jan 2009 17:46

Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.

sparklywater 14 Jan 2009 19:48

Quote:

Originally Posted by Bellardia (Post 1712285)
Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.

Any idea what javascript I can use?

thanks.

Dismounted 15 Jan 2009 05:01

Quote:

Originally Posted by Bellardia (Post 1712285)
Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.

However, I don't think you can fetch the width of a displayed cell in Javascript. The width as defined in the source code may be fetchable, but the width (in pixels) that it is currently displayed cannot.

sparklywater 15 Jan 2009 07:45

Quote:

Originally Posted by Dismounted (Post 1712918)
However, I don't think you can fetch the width of a displayed cell in Javascript. The width as defined in the source code may be fetchable, but the width (in pixels) that it is currently displayed cannot.

Well, it doesn't necessarily have to determine the width of the cell in pixels. I was wondering if there is a function which can determine when a text is flowing onto a new line, because this is what happens when the text hits the end of a cell, it moves onto a new line on the screen. So there won't be any need to work out the width of the cell. If a function can tell that the width of the cell has caused the text to flow onto another line, it can trim the string at that point to make it fit on one line.

Not sure if this is too much to ask, but may be possible somehow.


All times are GMT. The time now is 12:02.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.