[Rt-devel] Small patch to /Elements/MakeClicky
Robert Spier
rspier at pobox.com
Fri Mar 6 00:06:18 EST 2009
Tim Cutts wrote:
>
> Some users of mine didn't like the fact that we're using a space every
> 30 characters instead of using <wbr>, because it means copying and
> pasting the URL as displayed (rather than clicking on it) doesn't work
> correctly.
>
> Now, I realise that <wbr> is a bit broken on some browsers, but Google
> found what appears to be a useful workaround for those broken
> browsers, which is to use a bit of CSS. I could put that into each
> theme, but because this is a theme-independent thing, I've done it as
> inline CSS - I hope that isn't too abhorrent. I've also modified the
> regex to put the <wbr> at each / in the URL, or every 30 non-/
> characters, which most of the time makes it put the line breaks in a
> more meaningful location.
>
> The patch is as follows:
>
> --- share/html/Elements/MakeClicky 2009-02-03 11:53:02.000000000 +0000
> +++ local/html/Elements/MakeClicky 2009-03-05 17:52:30.000000000 +0000
> @@ -60,9 +60,11 @@
> },
> url_overwrite => sub {
> my %args = @_;
> - my $result = qq{<a target="new" href="$args{'value'}">};
> - #XXX: use spaces here. ­ <wbr> are not well supported :(
> - $args{'value'} =~ s/(\S{30})/$1 /g;
> + # Inline CSS is a fix for wbr in Opera/Safari, from
> + # http://gojomo.blogspot.com/2005/03/cross-browser-invisible-word-break-in.html
> + # and comments thereon
> + my $result = qq{<a style="wbr { display: inline-block; }"
> target="new" href="$args{'value'}">};
Wouldn't it be cleaner to just define
.clickylink a wbr { display: inline-block; } in the main CSS?
> + $args{'value'} =~ s:(/|[^/]{30}):$1<wbr>:g;
> $result .= qq{$args{'value'}</a>};
> return qq{<span class="clickylink">$result</span>};
> },
>
> So far I have tested this on Safari 4.0, Firefox 3.0.7 and IE 7, and
> it seems to be OK...
>
> Have I missed something?
>
> Tim
>
>
>
> --
> The Wellcome Trust Sanger Institute is operated by Genome Research
> Limited, a charity registered in England with number 1021457 and a
> company registered in England with number 2742969, whose registered
> office is 215 Euston Road, London, NW1 2BE.
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
More information about the Rt-devel
mailing list