Beware the Hard-Coded YUI Calendar Images
If you use the YUI calendar object, you may want to know that the URL’s for some of the images that are used are hard coded!! A big thanks to Firebug for making it easy to track that down, and for someone at Yahoo who added a configuration variable that makes the solution alot more palatable.
I would never have even noticed if we had not been experiencing some web traffic lag today when I noticed the status bar message about downloading from us.i1.yimg.com. I fired up Firebug, looked into the network profiler, and saw this…

Not something you want to see in your Intranet application, so I drilled into the calendar.js file to find this amazing piece of coding:


Of course, it is easy enough to simply change these values, but what are the odds that I would forget about the change after I do an upgrade to a new version?
In the end, I found a class property for the Calendar class called “IMG_ROOT”. This can be set inside the page to direct all calendar image references to a new location. Yet, did you notice they hard coded the sub-directories? So the end solution is to move the image files that the YUI library comes with, to different directories and to set the IMG_ROOT property.
The new file structure needs to look like this:

The x_d.gif file is not included with the library and needs to be downloaded here: http://us.i1.yimg.com/us.yimg.com/i/us/my/bn/x_d.gif.
To set the IMG_ROOT property, you only need a command like this before you declare and render your calendar(s) (I stuck with using the YUI paths):
YAHOO.widget.Calendar.IMG_ROOT = “js/yui.12.0/build/calendar/assets/”;
This approach is needed since some images are CSS background images which could have had their styles overridden, but some are IMG tags that need to be rewritten.
ugh!!
January 7th, 2007 at 7:22 am
Admin plz check http://www.crossedconnections.org/w/index.php/2006/04/26/scriptaculous-workflow-designer/#comment-10501 it about a former project of yours… thx (would have emailed you if I could find an adress)
January 24th, 2007 at 11:45 pm
Thanks! This saved me a world of hurt on my website when I realized all my calendar images had dissapeared!