public
Last active

RUZEE.Ellipsis for jQuery

  • Download Gist
gistfile1.js
JavaScript
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
/**
* RUZEE.Ellipsis 0.1
* (c) 2007 Steffen Rusitschka
*
* RUZEE.Ellipsis is freely distributable under the terms of an MIT-style license.
* For details, see http://www.ruzee.com/
*
* Modified for use with jQuery instead of Prototype.
* http://opensource.fooala.com/
*/
 
 
document.write('<style type="text/css">' +
'.ellipsis { margin-right:-10000px; }</style>');
 
$j(document).ready(function(){
$j('.ellipsis').each(function (i) {
var e = this;
var w = $j(e).width() - 10000;
var t = e.innerHTML;
$j(e).html("<span>" + t + "</span>");
e = $j(e).children(":first-child")
while (t.length > 0 && $j(e).width() >= w) {
t = t.substr(0, t.length - 1);
$j(e).html(t + "...");
}
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.