[string_truncate_fade]

Description

Link: [string_truncate_fade]
Author: Johan Sölve
Category: String
Version: 8.x
License: Public Domain
Posted: Jun. 24, 2009
Updated: Jan. 01, 0001
More by this author...
Fades out a string if it is too long, just as the address bar in Safari 4. Works best for black text on a white background, adjust the colors to use it on other backgrounds.

Parameters

-string string, required
-length integer, required

Sample Usage

string_truncate_fade('Too long string that needs to be truncated in a smooth way', 54);
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
define_tag('string_truncate_fade', 
	-required='string', -type='string', 
	-required='length', -type='integer',
	-encodenone);
	#string -> size <= #length ? return(#string);
	local('output'=#string -> substring(1,#length),
		'pos'=integer,
		'colors'=array('#666', '#999', '#bbb', '#ddd'));
	// create fadeout
	loop(4);
		#pos=(#output -> size) - (4 - loop_count);
		#output=string_insert(#output, 
			-position=#pos,
			-text=(loop_count > 1 ? '</span>') 
				+ '<span style="color:' + (#colors -> get(loop_count)) + '">');
	/loop;
	#output += '</span>';
	return(#output);
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net