02.06.2013 Views

JavaScript & jQuery: The Missing Manual ... - Robert Guajardo

JavaScript & jQuery: The Missing Manual ... - Robert Guajardo

JavaScript & jQuery: The Missing Manual ... - Robert Guajardo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced Gallery<br />

with <strong>jQuery</strong><br />

FancyBox<br />

ways to modify this. If you’re not happy with the 30-pixel by 30-pixel size, you<br />

can simply edit the fancybox.png file: Delete the 30×30 image in the top-right of<br />

that file and replace it with a design of your own.<br />

In the FancyBox stylesheet (the jquery.fancybox-1.3.4.css file included in the tutorial<br />

files), you can edit the #fancybox-close style for even greater control. In<br />

this style, you can control the placement of the Close button (change the top and<br />

right settings), the height and width of the button (change the height and width<br />

properties), and even point to a different graphic file by editing the background<br />

property.<br />

IE6 Note: FancyBox uses special CSS styles to overcome bugs in Internet Explorer 6. <strong>The</strong> styles don’t<br />

reference the fancybox.png file, but instead use different images for each of the controls. IE6 is a nearly<br />

dead web browser, so you’re most likely safe to ignore it, but if you’re still worried and want to change the<br />

appearance of the control graphics, then you need to edit the following image files: fancy_close.png (the<br />

close button), fancy_nav_left.png (the previous button), fancy_nav_right.png (the next button), fancy_<br />

loading.png (the animated loading image), fancy_title_main.png (for the center part of the caption<br />

graphic), fancy_title_right.png (for the right edge of the caption graphic), and fancy_title_left.png (for the<br />

left edge of the caption graphic). Or you can save yourself all this trouble and ignore IE6 altogether.<br />

• <strong>The</strong> Previous and Next buttons. As with the Close button, the Previous and<br />

Next buttons are images within the fancybox.png file (see Figure 7-7). You can<br />

edit that file (make sure to stay within the 30×30 pixel boundary). You can also<br />

use different graphic files and at different sizes by editing the styles for these two<br />

controls: a group selector (#fancybox-left-ico, #fancybox-right-ico), which provides<br />

properties (like width and height) that are common to both controls, and<br />

the individual styles (#fancybox-left-ico for the Previous button and #fancyboxright-ico<br />

for the Next button), which set the image for the controls.<br />

• <strong>The</strong> “loading” graphic. When a visitor clicks on a thumbnail to make a larger<br />

image pop onto the page, the browser has to download that file. While it waits,<br />

an animated image appears on the screen to indicate that image is being retrieved.<br />

This image is actually a series of “frames” in the fancybox.png file (see<br />

Figure 7-7). Its 12 frames are 40 pixels tall by 40 pixels wide. To change this<br />

image, you need to edit the fancybox.png file and create your own 12-frame<br />

animation. <strong>The</strong> CSS style controlling which image is loaded and its width is the<br />

#fancybox-loading div style. But if you want to control the placement, width,<br />

and height of the image, you need to also edit the #fancybox-loading style. It’s a<br />

lot of work, and since the normal “loading” graphic looks great, you may want<br />

to avoid changing it.<br />

• Drop shadows. <strong>The</strong> drop shadows that appear around the pop-up image are<br />

generated by a bunch of individual image files, including a couple of parts of the<br />

fancybox.png file. Editing these is complex and is best avoided. If you do make<br />

separate graphic files for the various controls discussed in this list and edit the<br />

CSS to point to those files, don’t delete the fancybox.png file—it supplies the<br />

corners for the drop shadows.<br />

230 javascript & jquery: the missing manual<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!