Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Implementing the preload functionality

From: Create an Interactive Photo Gallery with jQuery and Dreamweaver

Video: Implementing the preload functionality

Now to add our preload check into here, the first thing we need to do is pick a place to put the image so that we can perform the preload. So back in Dreamweaver, back in Code view, when we were first setting up our div structure, we created this class in here called gallery_preload_area. I am going to copy the name of this class to the clipboard. I am going to switch back over to our JavaScript file, and what we're going to do is that we want to run the preload after the fadeOut is happened. So we're actually going to come in here, add a few lines, I am going to put a Dollar sign, beginning and ending parentheses, two tick marks for string literal, dot and then Command+V or Ctrl+V for paste, gallery_preload_area.

Implementing the preload functionality

Now to add our preload check into here, the first thing we need to do is pick a place to put the image so that we can perform the preload. So back in Dreamweaver, back in Code view, when we were first setting up our div structure, we created this class in here called gallery_preload_area. I am going to copy the name of this class to the clipboard. I am going to switch back over to our JavaScript file, and what we're going to do is that we want to run the preload after the fadeOut is happened. So we're actually going to come in here, add a few lines, I am going to put a Dollar sign, beginning and ending parentheses, two tick marks for string literal, dot and then Command+V or Ctrl+V for paste, gallery_preload_area.

We're going to set the HTML, beginning and ending parentheses, a semicolon. Inside of here, we are going to set a string literal, image, source, equals, two quotes, forward slash, end bracket. And inside there, we're going to put a letter x. So what we're going to do is take the preload area and put an image tag in that area. Let's grab photo_preview variable, select the X, hit Delete, two tick marks, two Plus signs.

We're going to concatenate the string, photo_preview. On the next line, I am going to copy the declaration, picking that div. So we're going to say Dollar sign, .gallery_ preload_area img, so we are going to target all images that are inside the preload area, which we just added one on the line above. Now, we're going to use imgpreload.

This is the name of the actual function that's part of the far In image preload tool. Beginning and ending parentheses, then a semicolon. So this statement, this is the name of the plug-in. So once we hooked in the farinspace into our page, we can call this just like any other function and this will actually perform a preload on all of the images that are inside of preload area. Inside of here, let's add a function, beginning and ending parentheses, beginning and ending bracket.

This function is callback function, and it's only going to run after all the preload has happened. So let's open this up a little bit. So these are all of the things we want to have happen only after the preload has taken place. So, let's cut all this to the clipboard, put our cursor inside here, and let's paste all of this inside here. I will tab some of this in, so we can see the structure. So now when our full script happens, the anchor tags get clicked. We prevent the default.

We set the states of the thumbnails. We defined variables based on the thumbnail you clicked, which is this statement. We created a photo_preview URL because we don't actually use that in our HTML. We set the gallery_caption to slide up, we fade out the picture. Then we take the preload area, we put an image tag in it, then we run a preload on that to make sure that's been loaded. Then we update the HTML for the preview, update the HTML for the caption, and then we show the preview and show the caption. Let's hit File > Save. Let's come out to our operating system.

Let's double-click index.html, Command or Ctrl to reload. Now when I click on these images, the preload will happen and the type will fade up. Now, open this window up a little bit, and if we put this up on a web server where we have maybe a little bit of a slower Internet connection, or we put a really heavy preview file, a file with a big file size, we will actually see the preload happening. But also notice down here I have the image preload area, which is where the first image tag is getting written.

So as I click these, notice that on the right-hand side when the image fades out, we see the picture down below switch, and then we get the fade-up. So now what we need to do is set a CSS rule that hides that particular div. Let's come back over to Dreamweaver. Let's create a new CSS rule. This is going to be a class. We're going to set .gallery_preload_ area, click OK, Block properties, set the Display to None--we don't want the user to ever see that.

Let's choose File > Save All. Let's go back to our browser. We will hit Reload. Now, I can click on the images. The image will get written into that area we just set to be hidden with CSS, the preload happens, and then the content will fade back up. Now that our preload is working, now we want to add in our lightbox plug-in and set our overlay links.

Show transcript

This video is part of

Expand all | Collapse all
  1. 7m 51s
    1. Previewing the project across browsers and devices
      5m 32s
    2. About the exercise files
      2m 19s
  2. 9m 49s
    1. Renaming a series of files in Adobe Bridge
      3m 7s
    2. Using GREP for more intricate file renaming
      6m 42s
  3. 29m 5s
    1. Creating and linking HTML and CSS files
      1m 32s
    2. Save For Web & Devices in Photoshop
      7m 2s
    3. Creating empty CSS rules
      3m 55s
    4. Create, nest, and class DIV tags
      6m 0s
    5. Adding CSS properties for main container
      4m 0s
    6. Adding CSS properties for content area
      4m 28s
    7. Adding CSS properties for headings
      2m 8s
  4. 15m 55s
    1. Adding and linking the thumbnail images
      2m 32s
    2. Styling the thumbnail links with CSS
      5m 15s
    3. Downloading and adding jQuery to your project
      2m 42s
    4. Overriding the browser's default link behavior
      5m 26s
  5. 11m 10s
    1. Creating preview images from anchor links
      1m 52s
    2. Changing the preview when clicking thumbnails
      5m 59s
    3. Changing the caption when clicking thumbnails
      3m 19s
  6. 12m 0s
    1. Adding an image preload plug-in for jQuery
      2m 22s
    2. Setting a dissolve transition between previews
      4m 31s
    3. Implementing the preload functionality
      5m 7s
  7. 15m 20s
    1. Adding a lightbox plug-in for jQuery
      2m 2s
    2. Creating a custom function for lightbox properties
      7m 38s
    3. Setting links to activate the lightbox feature
      5m 40s
  8. 3m 40s
    1. Initializing the gallery on page load
      3m 40s
  9. 5m 11s
    1. Adding icons and styles to the zoom and contact links
      5m 11s
  10. 2m 41s
    1. Activating a gallery automatically in IE9 and IE10
      2m 41s
  11. 2m 43s
    1. Some ideas for further enhancements
      2m 43s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Create an Interactive Photo Gallery with jQuery and Dreamweaver.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.