-
1. Re: Spry Tooltip where you already have reference to element
Arnout Kazemier Oct 30, 2009 1:23 AM (in response to Phil_W)The best was is just to edit SpryTooltip.js
Inside the Spry.Widget.Tooltip.prototype.init replace :
this.triggerElements .... bla bla bla
with:
this.triggerElements = Object.prototype.toString.call(trigger_element) == '[object Array]' ? trigger_element : Utils.getElementsByClassName(trigger_element);
This will check if your selectors is actualy an array or not, if this his not the case it will use the getClassName functionality else it will use the array.
The array should be filled with dom node references.
-
2. Re: Spry Tooltip where you already have reference to element
Phil_W Oct 30, 2009 5:42 AM (in response to Arnout Kazemier)Hi,
Thanks for the above. I'll try making the change over the weekend.
Presumably it could do something similar for the tooltip element. Basically I'm using Spry.$ to do a more advanced (and much quicker) CSS selector on the dom elements I want to return as an array. Then I have a function which loops around matching various criteria against another array I have, then attaching tooltips based on conditions met. The Spry.$ is much faster I presume because I can use parent / child selectors to limit the number of nodes that need to be searched in the dom hierachy.
Are there any tools you can suggest to repack / minimise the tooltip.js file once I'm happy with my changes? Where in Dreamweaver CS4 would I need place my update to make the new tooltip.js the default for all new sites etc.
Thanks
Phil
-
3. Re: Spry Tooltip where you already have reference to element
Arnout Kazemier Oct 30, 2009 5:51 AM (in response to Phil_W)I use the YUI compressor for it.
http://yuilibrary.com/downloads/#yuicompressor
And for replacing your files i suggest reading this topic:
-
4. Re: Spry Tooltip where you already have reference to element
Phil_W Oct 30, 2009 6:11 PM (in response to Arnout Kazemier)Hi,
Yes that all works great.
Trick is to ensure passing an array of one element (or as many triggers as you wish) to the tooltip widget with your suggested amendment
So since I am only attaching the trigger to one element at a time I do the attached.
var selector = 'table#' + calID + ' td[class~="calcell"]'
// return array reference to table cells that make up calendar
tds = Spry.$$(selector);toolid = 't' + eventDates[nDate];
var myele = new Array;myele[0] = tds[r];
var t = new Spry.Widget.Tooltip(toolid,myele,{offsetY:25});where as var t = new Spry.Widget.Tooltip(toolid,myele[0],{offsetY:25}); will not work and in fact get an error saying element not in document...
Yes you guessed it's a yui calendar with highlighted cells and tooltips driven from Spry data. (which contains our club events)
www.thehmc.co.uk/events4.html - much much quicker to load now.
I'll take a look at the YUI compressor Sunday.
Phil


