-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·204 lines (176 loc) · 10.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Truncate: A jQuery Plugin</title>
<meta name="description" content="Truncate - a plugin that demonstrates text string manipulation with jQuery and JavaScript." />
<meta name="keywords" content="javascript, javascript string, jquery, css, xhtml, web development, web design, programming" />
<link rel="stylesheet" href="styles.css" type="text/css" media="screen, projection" />
<script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.truncate-2.3.2.pack.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$(".example_1").truncate( 8, {
chars: /\s/,
trail: [ " ( <a href='#' class='truncate_show'>more</a> . . . )", " ( . . . <a href='#' class='truncate_hide'>less</a> )" ]
});
$(".example_2").truncate( 60 );
$(".example_3").truncate( 120,{
chars: /\s/,
trail: [ " ( <a href='#' class='truncate_show'>more</a> . . . )", "( . . . <a href='#' class='truncate_hide'>less</a> )" ]
});
$(".example_4").truncate( 500,{
chars: /\s/,
trail: [ " ( <a href='#' class='truncate_show'>more</a> . . . )", "( . . . <a href='#' class='truncate_hide'>less</a> )" ]
});
$(".example_5").truncate( 10 );
});
</script>
</head>
<body>
<div id="wrapper">
<h1>
Truncate
</h1>
<h2>
A <a href="http://www.jquery.com">jQuery</a> Plugin by <a href="http://blog.reindel.com">Brian Reindel</a>
</h2>
<p class="description">
Truncate is a JavaScript plugin built for the jQuery library.<br />
It conserves space, preserves HTML, and is only 3KB.
</p>
<p class="version">
[ v.2.3 ] released February 11, 2008
</p>
<p class="contents">
<a href="#overview">Overview</a> | <a href="#notes">Release Notes</a> | <a href="#examples">Examples</a> | <a href="#download">Download</a>
</p>
<h3>
<a name="overview"></a>Overview
</h3>
<ul>
<li>
The JavaScript is 3KB, and the plugin is released under the <a href="http://www.gnu.org/copyleft/gpl.html">GNU GPL</a>.
</li>
<li>
The plugin has one required option, which is the maximum number of characters you would like to allow in an HTML string before truncating.
</li>
<li>
The plugin has two optional settings that can be modified. These options are <em>chars</em> and <em>trail</em>.
</li>
<li>
<em>chars</em>:<br />An acceptable set of characters (designated by a regular expression) to truncate in front of, once the max has been reached. If an acceptable character is not found at the max, the plugin will traverse the string backwards until one is found. If none is found, the string will not truncate. The default value is a single white space character.
</li>
<li>
<em>trail</em>:<br />An array that must contain two string entries (empty or otherwise). The first string is the "trail" that will follow truncated text. This can contain a link to expand the text back to the original HTML. The second string is reserved for a link that allows expanded text to be truncated again. The two class names you must use on these links are <em>truncate_show</em> and <em>truncate_hide</em>.
</li>
<li>
The plugin will clean up any single or empty HTML tag sets at the end of a truncated string, but it will not remove close tags associated with open tags at the beginning of a truncated string.
</li>
<li>
Please view the examples and source to better understand how the settings work.
</li>
</ul>
<h3>
<a name="notes"></a>Release Notes
</h3>
<p class="release">
<strong>February 11, 2008, v2.3 Release</strong>
</p>
<ul>
<li>
Supported jQuery Version: [ 1.2.3 ]
</li>
<li>
Supported Browsers: [ Windows IE 6+, FF 1.5+, Opera 9+ ] [ Mac Safari 2+, FF 1.5+, Opera 9+ ]
</li>
<li>
I finally managed to add support for preserving HTML. This was the most commonly suggested feature since the last release. The plugin code has changed significantly, and the major difference is that it now maintains two copies of the HTML string -- the original, and the truncated.
</li>
<li>
Next Release:<br />
If you have ideas for this plugin, please send them my way. I do not have anything in store for the next release at this time, except for any bug fixes.
</li>
</ul>
<p class="release">
<strong>August 08, 2007, v2.2 Release</strong>
</p>
<ul>
<li>
Supported jQuery Version: [ 1.1.3.1 ]
</li>
<li>
Supported Browsers: [ Windows IE 6+, FF 1.5+, Opera 9+ ] [ Mac Safari 2+, FF 1.5+, Opera 9+ ]
</li>
<li>
I received a few suggestions regarding the ability to expand and collapse the text that was truncated. I was a bit hesitant at first, thinking it would add unnecessary weight. However, I managed to come up with a solution that I think works well, and does not appear to affect performance.
</li>
<li>
Next Release:<br />
Thank you for everyone's comments and suggestions. If you have ideas for this plugin, please send them my way. I do not have anything in store for the next release at this time.
</li>
</ul>
<p class="release">
<strong>July 24, 2007, v2.1 Release</strong>
</p>
<ul>
<li>
Supported jQuery Version: [ 1.1.3.1 ]
</li>
<li>
Supported Browsers: [ Windows IE 6+, FF 1.5+, Opera 9+ ] [ Mac Safari 2+, FF 1.5+, Opera 9+ ]
</li>
<li>
The JavaScript for the plugin was optimized, and the <em>leave</em> option was added.
</li>
<li>
Next Release:<br />
Unless any improvements are requested, or bugs are discovered, then this will likely be the final release. I tried to provide a mechanism for truncating while preserving embedded HTML tags, but it proved to be unmanageable in every scenario. From the feedback I have received so far, the current iteration appears to be sufficient.
</li>
</ul>
<h3>
<a name="examples"></a>Examples
</h3>
<!-- Example 1 [ Begin ] -->
<div class="example_1">
1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec a lorem. Maecenas vel risus et eros vulputate sagittis. Aliquam at tortor. Nunc sit amet elit sit amet quam pellentesque condimentum. Etiam id nulla vitae massa imperdiet varius. Duis a quam. Duis faucibus lobortis velit.
</div>
<!-- Example 1 [ End ] -->
<!-- Example 2 [ Begin ] -->
<div class="example_2">
2. Nullam ac ligula. Nunc bibendum massa id purus. Nunc et ipsum. Donec tincidunt erat ac enim. Vivamus vulputate sapien ut nibh. Phasellus nonummy massa vitae lacus. Cras mauris. Praesent vitae purus. Nullam id risus ut purus scelerisque sollicitudin. Aenean tempor ultricies nisl. Aliquam varius leo eu quam. Etiam vitae massa. Donec dui nisi, rutrum sed, commodo sed, ullamcorper eget, purus. Fusce malesuada vestibulum felis.
</div>
<!-- Example 2 [ End ] -->
<!-- Example 3 [ Begin ] -->
<div class="example_3">
3. Etiam id nulla vitae massa imperdiet varius. Duis a quam. <ul><li>Duis faucibus lobortis velit.</li><li><em>In lacus sem, elementum nec, tempus id, tempor in, risus.</em></li></ul> Morbi rutrum lorem id mauris. Nunc et ipsum.<br />Donec tincidunt erat ac enim. Vivamus vulputate sapien ut nibh. Phasellus nonummy massa vitae lacus. Cras mauris. Praesent vitae purus.
</div>
<!-- Example 3 [ End ] -->
<!-- Example 4 [ Begin ] -->
<div class="example_4">
4. Etiam id nulla vitae massa imperdiet varius. Duis a quam. Duis faucibus lobortis velit. In lacus sem, elementum nec, tempus id, tempor in, risus. Morbi rutrum lorem id mauris. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec a lorem.
</div>
<!-- Example 4 [ End ] -->
<!-- Example 5 [ Begin ] -->
<!-- WARNING : "." is considered as a breaking char. That's why example 5 doesn't start with "5." : -->
<div class="example_5">Lorempictureipsumpicturedolorpicturesitpictureamet,pictureconsecteturpictureadipisicingpictureelit,picturesedpicturedopictureeiusmodpicturetemporpictureincididuntpictureutpicturelaborepictureetpicturedolorepicturemagnapicturealiqua.pictureUtpictureenimpictureadpictureminimpictureveniam,picturequispicturenostrudpictureexercitationpictureullamcopicturelaborispicturenisipictureutpicturealiquippictureexpictureeapicturecommodopictureconsequat.pictureDuispictureautepictureirurepicturedolorpictureinpicturereprehenderitpictureinpicturevoluptatepicturevelitpictureessepicturecillumpicturedolorepictureeupicturefugiatpicturenullapicturepariatur.pictureExcepteurpicturesintpictureoccaecatpicturecupidatatpicturenonpictureproident,picturesuntpictureinpictureculpapicturequipictureofficiapicturedeseruntpicturemollitpictureanimpictureidpictureestpicturelaborum.</div>
<!-- Example 5 [ End ] -->
<h3>
<a name="download"></a>Download
</h3>
<p class="download">
The packed version of the jQuery library is bundled with both the packed and unpacked version of the downloads.
</p>
<p class="download">
<a href="http://www.reindel.com/truncate/truncate-2.3.zip">Download Truncate</a> (Unpacked)<br />
<a href="http://www.reindel.com/truncate/truncate-2.3-pack.zip">Download Truncate</a> (Packed)
</p>
<p class="download">
For questions or suggestions, please send an email to <a href="mailto:[email protected]">[email protected]</a>.
</p>
<p class="download">
</p>
</div>
</body>
</html>