Prev | Current Page 386 | Next

Frank Zammetti

"Practical DWR 2 Projects"

src = "img/history0.gif";
var history1 = new Image(113, 22);
history1.src = "img/history1.gif";
var comments0 = new Image(113, 22);
comments0.src = "img/comments0.gif";
var comments1 = new Image(113, 22);
comments1.src = "img/comments1.gif";
CHAPTER 5 n SHARE YOUR KNOWLEDGE: DWIKI, THE DWR-BASED WIKI 213
this.imgOver = function(inImg) {
var imgName = inImg.id;
var img1 = eval(imgName + "1");
inImg.src = img1.src;
} // End imgOver().
this.imgOut = function(inImg) {
if (inImg.id != DWiki.currentMode) {
var imgName = inImg.id;
var img0 = eval(imgName + "0");
inImg.src = img0.src;
}
} // End imgOut().
} // End class.
// The one and only instance of RolloversClass.
var Rollovers = new RolloversClass();
It begins unassumingly enough by preloading a batch of images. These are the images
for our top and left navigation bars. This gives us nice, smooth rollover effects when the user
mouses over the items (otherwise, the images would be loaded upon that event firing, which
would cause a noticeable delay, at least the first time, while the alternate hover images were
loaded).
Following the preloads are two simple functions, imgOver() and imgOut(), fired correspondingly
in response to the onMouseOver and onMouseOut events hooked to the navigation
items.


Pages:
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398