forked from adamlukaszczyk/JS.FastEllipsis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (56 loc) · 2.86 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.FastEllipsis.js"></script>
<style type="text/css">
div {
padding:5px;
margin-bottom:10px;
margin-left:5px;
text-align:justify;
}
</style>
</head>
<body>
<script type="text/javascript">
$(function() {
function randOrd() {return (Math.round(Math.random())-0.5); }
function getRandomText() {
return ("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 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").split(" ").sort( randOrd ).join(" ");
}
var myEllipsis = new FastEllipsis("font-family: arial; font-size: 16px; letter-spacing: 0px;");
var longText = getRandomText();
$("#containterA").html(longText);
var ellipsed;
for (var i = 0, max = 1000; i < max; i++) {
ellipsed = myEllipsis.ellipseIt(
getRandomText(), // string to ellipsis
5, // maxline number
320 // width of container
);
$("<div style='background:#fcd; width:320px;font-family:arial;font-size:16px;letter-spacing:0;'></div>").appendTo("#conteinerB").html(ellipsed);
}
for (var i = 0, max = 1000; i < max; i++) {
ellipsed = myEllipsis.ellipseIt(
getRandomText(), // string to ellipsis
3, // maxline number
450 // width of container
);
$("<div style='background:#dcf; width:450px;font-family:arial;font-size:16px;letter-spacing:0;'></div>").appendTo("#conteinerC").html(ellipsed);
}
});
</script>
<div style="float:left;">
<p>Full text:</p>
<div id="containterA" style="background:#cdf; width:320px;font-family:arial;font-size:16px;letter-spacing:0;"></div>
</div>
<div style="float:left;" id="conteinerB">
<p>Ellipsised width 320px, 5 rows:</p>
</div>
<div style="float:left;" id="conteinerC">
<p>Ellipsised width 450px, 3 rows:</p>
</div>
</body>
</html>