forked from henrik/jquery.truncator.js
-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.html
86 lines (68 loc) · 2.98 KB
/
example.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jQuery HTML Truncator</title>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.truncator.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$('.example').truncate({maxLength: 24});
$('.exampleRed').truncate({maxLength: 24, linkClass: "toggle"});
$('.exampleNoHtml').truncate({maxLength: 80, stripFormatting: true});
$('.exampleNoLessLink').truncate({maxLength: 80, less: false});
});
</script>
<style type="text/css">
table { border-collapse: collapse; }
td, th { border: 1px solid #000; }
.toggle { color: red; }
</style>
</head>
<body>
<h1>jQuery HTML Truncator</h1>
<p>By <a href="http://henrik.nyh.se">Henrik Nyh</a>, forked and extended by <a href="http://renderedtext.com">Rendered Text</a>. See <a href="http://henrik.nyh.se/2008/02/jquery-html-truncate">the blog post</a> and <a href="http://github.com/renderedtext/jquery.truncator.js">source on GitHub</a>.</p>
<h2>Example 1</h2>
<div class="example">
<p>
Text!
</p>
<p>
Föö & <em>bar</em> baz!
</p>
<p>Giant <strong title="fool">baby</strong> head.</p>
</div>
<h2>Example 2: with a class added to the link</h2>
<div class="exampleRed">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<h2>Example 3: Handling HTML entities</h2>
<div class="example">
<p>&amp; <b>old</b> foo bar.</p>
</div>
<h2>Example 4: Handling tables</h2>
<div class="example">
<p>Hello!</p>
<table>
<tr><th>Foo</th><th>Bar</th></tr>
<tr><td>Lauren</td><td>Ipsum</td></tr>
</table>
</div>
<h2>Example 5: Strip HTML in preview</h2>
<div class="exampleNoHtml">
<p>Hello <em>emphasized</em>!</p>
<h3>Subtitle</h3>
<table>
<tr><th>Foo</th><th>Bar</th></tr>
<tr><td>Lauren</td><td>Ipsum</td></tr>
</table>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<h2>Example 6: Don't display "less" link</h2>
<div class="exampleNoLessLink">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</body>
</html>