Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (56 sloc) 2.86 KB
<!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>