[Pro] another tooltip question

Hopefully a quick question. Can I apply a tooltip to images (just images) that have been applied via cms. The usual © title etc. ? Using the alt text the client has entered.

Looked at all the tooltip examples and most are fine and easy but its the alt text / cms bit if possible I’m finding unclear. And yes I know alt text isn’t a ‘tooltip’ as such. A title attribute generally being required.

S


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Can you post a link to an example page where you want the tooltip to appear? Where there is a picture without a title attribute, but the text that would appear in that title attribute is to be found elsewhere on the same page? There’s doubtless a quick Prototype trick I could show you that would automatically create the attribute and populate it with the correct data.

Walter

On Dec 16, 2012, at 7:38 AM, seoras wrote:

Hopefully a quick question. Can I apply a tooltip to images (just images) that have been applied via cms. The usual © title etc. ? Using the alt text the client has entered.

Looked at all the tooltip examples and most are fine and easy but its the alt text / cms bit if possible I’m finding unclear. And yes I know alt text isn’t a ‘tooltip’ as such. A title attribute generally being required.

S


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

but the text that would appear in that title attribute is to be found elsewhere on the same page?

Hi Walter,

Not sure what you mean by that line but here is a link: www.pkht.org.uk/projects.php

Line 305 is the alt=

If its a hassle then no big deal to say no to client, it was just an after thought. Personally I would be happy just having image details at the bottom of the article. With more cms sites these days it might be useful.

thanks,

s


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This is pretty easy to do globally (attach a title to all images that have an non-empty alt tag) but without some other way to tell which images you mean to apply this method to, it becomes a bit scattershot. If you recall the bad old days of IE 3 and 4, when hovering over any image for any length of time would bring up this nasty overlay giving you the options to download it, imagine if every image on your site suddenly had a title attribute, and you couldn’t hover the mouse anywhere without triggering a tooltip.

So here’s two ways to do this. The first relies on you setting an empty alt attribute for any image that doesn’t need the tool-tip; the second relies on you including the letters “left parenthesis”, “lower-case C”, “right parenthesis” in that order in the alt text. (I didn’t put those together in text here, because it would just confuse any Web viewers – that combination of letters is automatically transformed into a Copyright symbol by the Markdown interpreter on the Web archive of this list.)

To begin (for either approach) apply the Protaculous Action to your page, and choose prototype-packed from the Library menu. Click on the top Function Body button, and paste in ONE OF THE FOLLOWING snippets (not both).

$$('img[alt!=""][title=""]').each(function(elm){
	elm.writeAttribute('title', elm.readAttribute('alt'));
});

or this

$$('img[alt*="(c)"][title=""]').each(function(elm){
	elm.writeAttribute('title', elm.readAttribute('alt'));
});

(Hopefully, that second example doesn’t have a copyright symbol sitting in the middle of it if you’re looking at this on the Web.)

So the first of these will add a title to any image that has a non-empty alt attribute, and the second will only attach to elements that 1. have a non-empty alt, and 2. have an alt that contains the letters ( c ) (together).

Walter

On Dec 16, 2012, at 11:48 AM, seoras wrote:

but the text that would appear in that title attribute is to be found elsewhere on the same page?

Hi Walter,

Not sure what you mean by that line but here is a link: www.pkht.org.uk/projects.php

Line 305 is the alt=

If its a hassle then no big deal to say no to client, it was just an after thought. Personally I would be happy just having image details at the bottom of the article. With more cms sites these days it might be useful.

thanks,

s


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Excellent, thanks again Walter.

I’ll give those a go. The copyright symbol isn’t an issue as I can instruct client to just use ‘copyright’. Thankfully I’ve a client who’s taking heed of instructions reasonably well.

s


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Just to be clear, the only issue with copyright (the symbol) is with the FreewayTalk Web site. There’s no restriction on your own site, because you’re not running user-generated code through a translation and sanitization system, as we do here.

If you look at this thread on the Freewaytalk Web site, you might see a © in places where the letters ( c ) were typed without any spaces between them. But I just checked, and I don’t see that in my code example, so no need to worry at all.

My code as written EXPLICITLY looks for (c) rather than for © – your client should use and continue to use the ASCII equivalent, rather than the Unicode (Option-G) character, since the former will be entirely HTML-safe without needing to be converted into © or a numerical equivalent.

Walter

On Dec 16, 2012, at 12:27 PM, seoras wrote:

Excellent, thanks again Walter.

I’ll give those a go. The copyright symbol isn’t an issue as I can instruct client to just use ‘copyright’. Thankfully I’ve a client who’s taking heed of instructions reasonably well.

s


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

My code as written EXPLICITLY looks for (c) rather than for © — your client should use and continue to use the ASCII equivalent, rather than the Unicode (Option-G) character, since the former will be entirely HTML-safe without needing to be converted into © or a numerical equivalent.

(c)ool.

s:)


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options