Just a side not ... if all you are using is the width and height methods and
you are only calling it on DOM elements, you don't need to include
dimensions. Dimensions adds the ability to call it on window and document
but that is all.

--
Brandon Aaron

On 8/13/07, Tane Piper <[EMAIL PROTECTED]> wrote:
>
>
> Hey folks,
>
> I took up the challenge of Steffen Rusitschka to convert his Ellipsis
> code from Prototype to jQuery.  Unfortunately I decided to do this at
> the end of my work day as a little aside, and haven't managed to crack
> it yet - so I'm posting what I have so far to see if anyone can fix it
> - My demo is here: http://dev.digitalspaghetti.me.uk/ellipsis/
>
> His original code is here:
>
> http://www.ruzee.com/blog/2007/08/ellipsis-or-truncate-with-dots-via-javascript/
>
> And here is what I have so far (please note it uses the Dimensions
> plugin):
>
> (function($){
>         $.fn.ellipsis = function(){
>                 $(this).css({marginRight: '-10000px'});
>                 var w = $(this).width() - 10000;
>                 var t = $(this).html();
>                 $(this).html('<span>'+ $(this).html() +'</span>');
>                 while (t.length> 0 && $(this).children().width()>= w) {
>                         t = t.substr(0, t.length - 1);
>                         $(this).children().html(t + "...");
>                 }
>         }
> })(jQuery);
>
> I did a console.log on 't' inside the while, and it does remove the
> characters one by one, but doesn't seem to stop.  If anyone can figure
> it out (probably easy but I've had a long day), you get the cookie.
> It's also very slow, so if you can figure out a way to speed it up,
> that would be handy too.
>
> --
> Tane Piper
> http://digitalspaghetti.me.uk
>
> This email is: [ ] blogable [ x ] ask first [ ] private
>

Reply via email to