Create an Interactive Photo Gallery with jQuery and Dreamweaver

Create an Interactive Photo Gallery with jQuery and Dreamweaver

with Chris Converse

 


In Create an Interactive Photo Gallery with jQuery and Dreamweaver, author Chris Converse develops an interactive photo gallery for a web site using HTML, CSS, and the open-source JavaScript library jQuery. The course begins with tutorials on extracting different-sized images sets from an original photo collection, designing the site layout, and constructing the HTML and CSS. Then, following the progressive enhancement strategy, Chris utilizes JavaScript plug-ins to include lightboxes and other types of interactivity while maintaining backwards compatibility with older browsers and devices. Exercise files accompany the course.

Download a copy of the finished web site here.
Topics include:
  • Preparing gallery photos using Adobe Bridge
  • Adding and linking thumbnail images
  • Creating the layout in HTML and CSS
  • Downloading and adding jQuery to the project
  • Creating preview images from anchor links
  • Implementing the preload functionality
  • Building a customized lightbox with the Fancybox plug-in
  • Styling the zoom and contact links

show more

author
Chris Converse
subject
Developer, Photography, Web, Sharing Photos, Web Design, Projects, Web Development
software
Dreamweaver CS3, CS4, CS5, CS5.5, jQuery
level
Intermediate
duration
1h 55m
released
Apr 27, 2011

Share this course

Ready to join? subscribe


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Previewing the project across browsers and devices
00:00Hi! I am Chris Converse, and this is a course about creating your own photo gallery.
00:04I want to start by taking a look at the final project that we're going to be creating.
00:08When you download the assets, there's going to be a Final Project folder where
00:11you can open these files in your web browser and take a look at what the user
00:15experience is going to look like once we're done programming this.
00:17I am going to start by taking the index.html file and opening it up in a web browser.
00:24So in here I have a series of thumbnails.
00:25When the gallery loads automatically, the very first image actually fades up
00:29over on the right-hand side.
00:30As I move my cursor around the thumbnails, I get a little highlight.
00:34Clicking on a thumbnail will fade down the particular thumbnail I clicked on,
00:38show me a preview image slightly larger version of the thumbnail, show me a
00:42caption, give me links at the bottom.
00:44If I click on the preview, we actually load this up in a lightbox and this is
00:49the higher-resolution file, so there's three versions of each photograph that
00:53we're going to be working with.
00:55The caption will close up, the picture will load, and then change.
00:59We also have a preload set in here, so as we click on the items, the preview
01:03image over on the right-hand side has a jQuery plug-in attached to it that will
01:07automatically preload the image and then fade it up,
01:10so we don't have that case where the image just pops on because it started to
01:14animate before it preloaded.
01:17The text areas underneath are going to be dynamically created on the right-hand
01:20side, so the VIEW LARGER link will also initiate a lightbox which will overlay
01:25the high-resolution file over the top.
01:27And this will also give us dynamic captions in the lower left-hand corner as well.
01:31On the left-hand side, we have an email link that we can click and initiate an email.
01:39And the technologies we're using here: we're using HTML, CSS, and JavaScript.
01:43To help us with the JavaScript, we're going to be using an open-source
01:46framework called jQuery.
01:47And in addition we're going to be plugging in two open-source frameworks in the jQuery:
01:51one called Fancybox to do the Lightbox overlays and one called far IN space to
01:56do the preload images.
01:58Now, one of the advantages of using a framework like this is that we can go
02:01across multiple platforms and multiple devices and get the same user experience.
02:06Here I am going to hop over to Windows and we're going to come down to load the
02:10same project in Windows XP, all the way back to Internet Explorer 7, and we're
02:15going to get the same user experience this far back.
02:18I can click on the different thumbnails.
02:21I can click on VIEW IMAGE.
02:22Now, this experience will also work in IE 6, although we won't get some of
02:27the transparent effect.
02:28So we've got this sort of light drop shadow that we get from Fancybox and this overlay here.
02:33Some of that's won't show up in IE;
02:35they'll just be solid pictures. So this will work in IE, but it won't be the
02:39optimal user experience.
02:41And in addition to platforms--let's close out of Mac and Windows here--
02:47we can also load this up in mobile devices.
02:50So here we're looking at a version of Android.
02:55So in Android here, I am going to come in to the web browser. I'm going to come up to my Favorites.
02:59I am going to load the same files in the Android environment.
03:08I am going to hit Ctrl+F11 to rotate the device.
03:12I can tap on an image;
03:15I get the fade-in and then fade-out.
03:19Tap on the full picture,
03:20I get the lightbox that comes up.
03:26And then lastly, we get the same sort of user experience with the iPad and other tablets,
03:31so Android tablets, iPad tablets.
03:33I'll rotate this device, holding Command+Right Arrow, click on these items and
03:41again activate the lightbox as well.
03:43The other development technique that we're going to use in building this
03:46particular project is a technique called progressive enhancement.
03:49And so what that means is we're going to build the HTML in such a way that even
03:54if somebody doesn't have full CSS support, or they don't have JavaScript at
03:59all, the way the HTML is going to be built, they can still go through our photo gallery.
04:04So in the exercise files, I have two additional files.
04:07One's called index_no_js.
04:10So I am going to take this file and load it in a browser.
04:13So if somebody visits your site and they don't have JavaScript--so maybe
04:15they're using an earlier phone that has a web browser, but it doesn't have
04:19JavaScript support--
04:20they can still visit your site.
04:22They can click on individual images.
04:24These will link over to the high-res files and they can simply use their
04:27browser's Back button or their phone's Back button to go back to the main menu.
04:32So they can still participate in the gallery and look at all the photography,
04:37and they just have the slightly different user experience.
04:40In a case where they might be on a much older mobile device that doesn't have
04:44any CSS or JavaScript support, this particular code base would look like this.
04:49They would just see a series of thumbnails, no styling, no background graphics,
04:53but again, each one of these images has linked to its high-res file.
04:56So they can simply just tap or move their control wheel over to the item, click
05:01the OK button, and activate each one of these links.
05:05So using this progressive enhancement technique, we can create a single HTML
05:09file with base functionality and then enhance the user experience if they have
05:14JavaScript, if they have CSS, and we only build one file.
05:18And then the individual browsers that people visit our gallery with will then
05:22dictate what the full user experience can be based on those particular
05:25browser's capabilities.
05:26So I hope this sounds interesting to you, and if so, let's get started with the
05:30first chapter.
Collapse this transcript
About the exercise files
00:01When you download the exercise files, there's going to be two folders contained
00:04inside of that download:
00:05an Art Templates directory, which is going to contain all of the source
00:08Photoshop files we're going to use to create the assets for our photo gallery,
00:13and in addition there's going to be Photos for Gallery, which is going to
00:16contain all of the higher-resolution photography we're going to use to load
00:19inside of the Lightbox.
00:20This is going to be the highest-resolution previews we're going to offer
00:23though our web gallery.
00:24The page_template.psd contains all of the artwork we're going to use for the
00:29outer shell to create the design of our gallery.
00:32And the two Photoshop files-- preview_sizes and thumbnail_sizes--are going to
00:35be the custom cropping that we're going to use to get the optimal design and
00:39cropping of each of our photographic images for our gallery.
00:43Inside of Final Project is going to be all the files we're going to create
00:46by the end of the class.
00:48We're going to be creating the file index.html, but I've also included the
00:52non-JavaScript version and the non-JavaScript and non-CSS version.
00:56When we looked at the introduction video, we saw how this particular technique
01:01is going to progressively enhance our user experience.
01:04But I wanted to include these files so you could take a look at these and
01:07see what the site would look like on a browser that doesn't support JavaScript or CSS.
01:13Inside of the includes directory we're going to download a copy of jQuery 1.5.
01:17We're also going two download two additional plug-ins.
01:19We're going to get a copy of Fancybox, which is a jQuery plug-in which allows us
01:24to add a lightbox to our gallery, and a copy of far IN space, which is a plug-in
01:29that allows us to target a particular div and preload all of the images
01:33inside so that we can preload images before we do our fade-up and fade-down
01:37of our preview images.
01:39And then lastly, inside of the images directory we're going to have a template
01:42directory, which is going to contain all of the artwork that's going be used in
01:45the outer shell and design of our gallery.
01:48And inside of the gallery directory itself is going to be all of the photography
01:52that's going to be used in the gallery.
01:54Every one of the photographs is going to have three different versions.
01:56We're going to have a full-size version, which is going to be the graphic we
01:59load into the lightbox.
02:00We've got the preview graphic, which going to be the graphic on the far right.
02:04And then we've got the thumbnails which are the small graphics we're going to
02:07have on the left-hand side of our design.
02:08Let me close up these folders, and the first thing we're going to do is start
02:12from one of our Art Template directories inside Photo Galleries, and we're going
02:16to create some folders on the desktop and start our project.
Collapse this transcript
1. Preparing the Gallery Photos
Renaming a series of files in Adobe Bridge
00:01To begin our project, we're going to create series of folders. On the desktop,
00:05we're going to start with a folder called myGallery. I'm going to open up this folder,
00:14and inside of here we're going to create another series of folders.
00:20First, we'll create includes.
00:21This is going to hold our CSS and JavaScript files.
00:23Another folder called images, another folder called template, and another
00:33folder called photos.
00:38Going to take photos and templates, Shift+Select them, and bring them into
00:42the images directory.
00:46Now that I have this in place, let's come back to the exercise files.
00:48Let's go into the Photos for Gallery.
00:50I am going to Shift+Select all of the pictures, hold the Option or Alt in
00:56Windows, and drag a copy of all of these JPEG files into the photos directory
01:00inside of the myGallery directory we just created for our project.
01:03Let me close up the exercise files.
01:07Now, all these JPEGs in the photos directory are going to be the
01:12high-resolution files,
01:13so I want to name them with _fullsize in the file name.
01:17So instead of renaming each one, I am going to use Adobe Bridge.
01:19Going to take the photos directory and just drag and drop at right on top of Adobe Bridge.
01:25Inside of Bridge, if we drag a folder on top of the Bridge icon, it will
01:28automatically open that folder in our operating system here.
01:32And by default, I have a Content panel here and a Preview panel.
01:35Selecting items down here in Content will show me the preview here.
01:39Holding the Command or Ctrl key in Windows, I can select multiple files.
01:44I'm going to come down and choose Edit > Select All to select all of the files.
01:48Let's come under the Tools menu and choose Batch Rename.
01:54Inside of this dialog box here, I am going to come down here and choose Default.
01:58This will be the first screen that you're going to see when you've run Batch Rename.
02:02And down here we basically are going to construct the new file names we want
02:05to have Bridge rename all of the files to.
02:08So we're going to start with the first one and choose Current Filename.
02:11And the first item here is just going to be Name.
02:14Let's take off Name and Extension.
02:16Let's come over here to the Minus signs and let's delete two of these parameters.
02:21And instead of Date and Time, let's change this to Text, and we're going to come
02:25in here and type _fullsize.
02:29I am going to come over here and click Preview.
02:32Bridge is going to show me the original file names over here on the left with
02:36the brand-new file name.
02:37It's going to rename everything on the right-hand side.
02:39That looks right, acrobats_fullsize, apartments, berries.
02:42Let's choose OK and let's hit Rename.
02:46Come back to our operating system.
02:48I can see all of the files have now been renamed with _fullsize in the file name.
02:52Let's come over and close Bridge.
02:56Now that we have our fullsize files ready, in the next movie we're going to
03:02open up the preview and thumbnail sizes and we're going to export those from
03:05Photoshop.
Collapse this transcript
Using GREP for more intricate file renaming
00:00Now in the exercise files let's open the preview_sizes.psd.
00:05Now, what I've decided to do here is to take each photograph one by one and
00:10custom crop each one of these photographs so that I get the optimal preview image.
00:16If I open up the refraction_fullsize. jepg, this is the size of the large file
00:21we're going to load into the lightbox. And instead of using automated tools
00:25like tools found in Photoshop or Bridge or Lightroom that will automatically
00:30resize a series of images,
00:32I want to spend the time and custom crop to get exactly the look that I want
00:36from taking this horizontal picture into a square picture we're going to use
00:38for our preview.
00:39So I've created these two Photoshop files with all of the layers labeled exactly
00:45the same file names as the full-size images that we just moved over from the
00:49full-size graphics in the exercise files.
00:52So what I want to do here is export from this Photoshop file out to a series of files.
00:57So what I'm going to do first, on the desktop, I'm going to click right here and
01:00create a new folder just called temp.
01:04Let me open that up, and I just want to place that I can save all of these files.
01:12Let's come back to Photoshop.
01:13Let's go to the File menu. Let's come down to Scripts > Export Layers to Files.
01:21In this dialog box here, I'm going to choose Browse > Desktop > temp folder. Let's choose Open.
01:28We'll keep JPEG, 8 Quality, and I want to make sure prefix here set to blank, and
01:35I'm going to choose Run.
01:37As Photoshop is running through all the layers and saving them out, I can see in
01:39the background all the files getting generated.
01:41Now, one of the things that I can't control is Photoshop is going to name every
01:46one of the files with an underscore plus a number in addition to the name of the layer.
01:50So we're going to use Bridge to get rid of all of this as well using the batch-
01:54rename process again.
01:55So on the desktop, I'm going to grab temp. Let's drag it into Bridge.
02:03In the Content area, I'll select the first photo, choose Edit > Select All.
02:10In Tools, we'll choose Batch Rename.
02:12Now this is going to be a little bit trickier because down here in the Preview
02:17I can see that every one of those files has additional content.
02:20So in addition to adding an extension of _preview before the .jpg, I also want
02:27to remove these numbers. But each one of these numbers are unique.
02:31So what we're going to do is use some grep search and replace inside of here as well.
02:35So to start, let's come up here to Filename.
02:37Let's come down and choose Current Filename, set this to Name.
02:41I'm going to get rid of two of these parameters for the moment.
02:47Under Date and Time, let's come down and choose String Substitution.
02:51I am going to come in here and choose Intermediate Filename, which means it's
02:56going to not append this to the additional file name, but concatenate the two together.
03:01And again, I can see a live preview down here of how my equation up here is
03:06actually going to rename the file.
03:10So under Find text, I'm going to put two square brackets and inside of here, I'm going to
03:14type 0-9, and this is going to be a grep expression, a regular expression.
03:20So I'm going to click on the Regular Expression check box, and notice that now
03:24all of the numbers went away.
03:26If I turn on Replace All, it will only replace one. Turn on Replace All gets rid of all of him.
03:32And up here after the 9, I'm going to put a comma and an underscore.
03:37So basically what this is saying is through grep,
03:41Bridge is going to find every instance of a number between 0-9 and any instance
03:46of an underscore, and it's going to replace it with blank text.
03:50It's going to do that for every piece of data that it finds and matches this in
03:53the file name with Replace All selected, and the check box Use Regular
03:57Expression will go through.
03:59So now I can see that my file name is now just the word refraction.jpg.
04:05Let's add one more parameter under Text. And at the end, we're going to add preview.
04:15Let's choose Preview at the top to make sure that all my file names will
04:18be renamed correctly.
04:20So _000_refraction becomes refraction_preview.jpg. Let's click OK.
04:28Now let's come up here and hit Rename. Bridge is going to run this rename.
04:33Let's come out here, and we can see that all of the files have now been renamed
04:38with 'preview' in there.
04:40Let's bring up our myGallery project. Let's grab all of these files from the temp
04:46directory and we'll drag and drop them right into the photos directory.
04:53So now we have all of our full-size and preview images.
04:56I'll leave this temp directory here.
04:58Let's close this window in Bridge.
05:00Let's close our preview_sizes.psd in Photoshop.
05:04And let's open thumbnail_sizes in Photoshop.
05:08Same process, I've named all of these layers exactly the same names.
05:11Let's choose File > Scripts > Layers to Files. Browse > temp directory. Click OK. Hit Run.
05:29Let's choose OK. There is our temp directory.
05:33Let's grab the temp directory.
05:34Let's drag this into Bridge, select the first one in Content, Select
05:40All, Tools > Batch Rename.
05:45Bridge is going to remember the last settings we had. And instead of _preview,
05:54this will be _thumbnail.
05:57Click Rename. Go back to Bridge.
06:00These have all been renamed.
06:02Let's close Bridge.
06:06Let's select all of these. Let's drag these into our myGallery project in the photos directory.
06:12Let's close temp. Throw that in the trash.
06:15Let me double-click on the photos directory just to see that by itself, and I
06:22see there's 60 items in here: 20 pictures for our gallery, including three
06:28different states of each one.
06:29Let's close the photos.
06:31Let's come back to Photoshop.
06:32Let's close thumbnail_sizes.
06:33Now at this point, we're done preparing all of our photography, so let's move
06:39into HTML and CSS.
Collapse this transcript
2. Creating the Layout in HTML and CSS
Creating and linking HTML and CSS files
00:00Now, we'll need to create an HTML file and a CSS file and hook the two together.
00:05Let's start by going to Dreamweaver, choose File > New > HTML.
00:11Let's choose XHTML 1.0 Transitional, so this will work all the way back in XP
00:16and as far back as IE 7 for some of the techniques we're going to use.
00:20With this brand-new file, let's choose File > Save, make sure we're in the
00:26myGallery directory. We'll call this index.html. Click Save.
00:33Create a new file, CSS, click Create.
00:40Let's choose File > Save.
00:42Let's save this into the includes directory. We'll call this gallery.css. Click Save.
00:49Now, let's come over and select the index file. Inside of Dreamweaver, we're going
00:55to attach the style sheet into this document.
00:58We're going to choose Format menu > CSS Styles > Attach Style Sheet. Click
01:04Browse > myGallery > includes > gallery.css Then click Choose. Then say OK.
01:14We now have our CSS file looked into our HTML file.
01:18Let's choose File > Save All.
01:21Now with our HTML and CSS file in place, in the next movie we're going to refer
01:25back to our sketch and we're going to start creating some CSS rules that are
01:28going to help us recreate our layout in HTML.
Collapse this transcript
Save For Web & Devices in Photoshop
00:00So now we that have our HTML and CSS files created and our external file links to the CSS file,
00:07I'm going to minimize this. And now what we want to do is create some of the
00:11assets that we're going to need from Photoshop, some of the graphics, to
00:14recreate our layout.
00:15So one of the first things I recommend doing in any interactive project and web
00:19site project is coming up with a sketch.
00:23You can draw this out in a notebook or use something like Illustrator or
00:26InDesign, and just come up with some of the measurements of the different
00:29pieces we're going to need, so that we can create individual slices inside of
00:33Photoshop and then recreate CSS in order to recreate some of those objects.
00:38So in this sketch here, what we're going to be creating for our photo gallery
00:41are a series of thumbnails that are going to be 75 x 75 pixels.
00:45Our preview areas is going to be 375 pixels wide.
00:48We're going to have the container that's going to be 500 pixels wide
00:51that's going to hold all of the thumbnails. And then we're going to have our
00:54overall gallery area be 960 pixels wide, and that's going to consist of the top
01:00area, a center tile area which is going to tile vertically--
01:04we'll set up with CSS--
01:05and a page bottom area.
01:09So letting this sketch sort of inform some of the numbers we're going to create,
01:12let's come out to the exercise files and let's open up page_template.PSD.
01:16Now inside of this file--I'm just going to zoom up here--
01:20we basically have just the artwork that we need to cut up and create our layout from.
01:26So in the left-hand area here, we have this sort of rounded-corner box with a
01:31gradient at the top and the bottom. And on the far right, if I scroll over, I
01:34can see little icons for the envelope and the magnifying glass, which we're
01:38going to use to create email links and the magnification, which is actually
01:42going to trigger the light box we looked at in the introduction video.
01:44So I'm going to scroll all way over to the left.
01:49Over here under the Cropping tool, we're going to come down and select the Slice tool.
01:52What the Slice tool allows us to do is draw artwork on top of our canvas, and
01:57when we use the Save for Web & Devices feature inside of Photoshop, any artwork
02:01inside of the slice areas can be saved out as an individual graphic file.
02:05So to use this, I'm going to come up here to the upper left-hand corner.
02:09I'm going to click and drag.
02:10That's going to create a slice area.
02:12Any slice that I draw will be highlighted in blue inside of Photoshop, and any
02:17slice that Photoshop creates to fill out the entire canvas will show up here in gray.
02:21When I move my cursor inside of here, I get the Slice Selection tool.
02:25I'm going to double-click and bring up the Slice Options panel.
02:28This is going to be the page top,
02:30so let's come in here and rename this page_top.
02:35The Width is going to be 960.
02:37It's going to be 20 pixels tall.
02:39I'm going to click OK.
02:40Now, that's going to create a slice.
02:43If I scroll out here, I can see that that will actually fit exactly the rounded-
02:47corner box, which I've drawn to be exactly 960 pixels wide.
02:50Scroll back to the left.
02:54Let's draw out another slice.
02:56This is going to be called page_tile.
02:59This is going to be 960.
03:03I'm going to set this to be 10 pixels tall.
03:06Now, this graphic here is going to be a tile, so it's going to repeat vertically.
03:11Now some people recommend making your graphic that's going to tile
03:15vertically only be one pixel tall, or a graphic that's going to repeat
03:19horizontally to be one pixel wide.
03:21I recommend against this because that means that the device or browser you are
03:25looking at has to paint that graphic that number of times.
03:29So if you have a 1024-wide site, the browser is going to have to paint that one
03:33graphic 1,024 times.
03:35So I recommend setting the graphic to at least 10 pixels, or even 20 pixels.
03:40The amount of file size difference is really tiny, but it drastically reduces
03:44the number of times the browser has to redraw those graphics.
03:49So I'll set this 960 x 10.
03:53Then lastly, last come down here, draw out another slice.
03:56This is going to be page_bottom. 960 x 20. We'll click OK.
04:06With this one selected, I'll use my arrow keys and I will just arrow this up.
04:09Let me zoom up here.
04:12I want to make sure that slice is right at the bottom of this area here, so
04:16that rule at the bottom of the rounded-corner box is right at the bottom of the slice area.
04:22Use my Zoom tool and zoom out here.
04:23Let's scroll all the way out to the right.
04:26I want to zoom up over here onto the envelope and Zoom tool.
04:30Slice tool is selected.
04:31I'm going to create two graphics here, 23 pixels x 15.
04:39This is going to be called link_email.
04:43Draw another one around the zoom.
04:52This one we'll called link_zoom. Then click OK.
04:56Use my arrow keys and move that down.
04:59So if I zoom up here, I want to make sure the magnifying glass fits perfectly
05:02inside of the slice area. And scroll up to the envelope, make sure that fits in there as well.
05:07I'm going to hit Command+Option+0 or Ctrl+Alt+0 on Windows to come out to full-screen view.
05:15I'm going to come over to the background and turn that off.
05:19I want these to be transparent.
05:22So these slices over here are going to be transparent against the background.
05:26These over here are going to be JPEGs without transparency.
05:29Let's choose File > Save for Web & Devices.
05:32I'm going to zoom up here.
05:37I'm going to scroll over to the right-hand side, so I can see most of my slices here.
05:43So I'll select the very first slice, hold Shift, select middle, and bottom.
05:47We're going to set these to JPEG, about 75% Quality.
05:52I'm going to select on the Envelope tool here.
05:56This is going to be a PNG file, 24.
06:02Select the Zoom Magnification tool.
06:04This is going to be PNG-24 as well. Let's click Save.
06:08I am going to choose the Desktop > myGallery > images, and we're going to choose template.
06:17Under Slices, I'm going to choose All User Slices.
06:19So even though Photoshop set up slices for all of the different canvas areas, we
06:23only want to save out the ones that we drew.
06:27Under Settings for Other, I want to come in here and make sure that Photoshop is
06:29going to save out each one of these as the slice name.
06:33We'll click OK. Then we'll hit Save.
06:36Let's go back out to the operating system.
06:38We'll close up photos, open up templates, and inside template, we'll have
06:42link_email.png, link_zoom.png, and then top, tile, and bottom JPEG files.
06:47Let's come back to Photoshop.
06:51Let's close and save our changes.
06:55So now that we have all of our graphics in place,
06:56let's go back over to Dreamweaver and create our CSS rules in order to recreate
06:59this layout in HTML and CSS.
Collapse this transcript
Creating empty CSS rules
00:00Now that we have the images in place and all of the assets we need for our
00:03template, let's come back over to Dreamweaver.
00:07Start in here, on each project I usually make a decision whether I'm going to
00:10build the HTML or the CSS first.
00:13Referring back to our sketch, this sort of informs the CSS rules and the
00:17dimensions of the objects we need to create in our CSS.
00:21So what I'm going to do here is I'm actually going to divide this.
00:24We're going to create our CSS rules first, leave them blank, and then we're
00:28going to go into HTML and build the HTML structure, so that we get all the
00:31nesting properly in place with all of the right classes.
00:34So to start with my HTML file open over here in the CSS panel in Dreamweaver,
00:39let's come down here and click on New CSS Rule.
00:42All the rules we're going to create are going to be classes, and let's start off
00:48creating one called page_container. We'll click OK.
00:55I'm going to leave all of this blank for moment.
00:57I'm going to create another new rule.
01:01This one is going to be called .gallery-credit. Click OK.
01:13New rule, this one is going to be called .gallery_type. Click OK.
01:23Create another rule. This one is going to be called .gallery_top.
01:29This one is actually going to be the top of the rounded-corner box, and we're
01:34going to use the Photoshop slice in this one. Choose OK.
01:38gallery_content, choose OK.
01:51New rule called .gallery_thumbnails. Click OK. New rule called .gallery_preview. Choose OK.
02:12New rule called .gallery_contact. Click OK. New rule called .gallery_caption. Click OK.
02:32Another one called .gallery_bottom. Choose OK.
02:44Then the last one we're going to create, .clear_both.
02:53Choose OK, and in this one, we'll go ahead and define the properties here.
02:56Let's come down to Box properties, come down to Clear, and select both.
03:01This is going to be a class that we're going to use to clear out different float
03:07objects that we're going to be assigning to our layout.
03:09The other thing I like to set inside the Type settings is the line height and
03:13set this to a height of 1 pixel. Then click OK.
03:19Now this gives us all of the CSS rules we're going to need.
03:25If I click over to the CSS rules here, we can see all of these are empty
03:29except for clear_both.
03:30But actually having these rules defined in the CSS here inside of Dreamweaver,
03:35in HTML Code view we can actually access these, and Dreamweaver will give us
03:39some code hinting and quick shortcuts to assign these into the proper nested
03:43structure for the HTML.
03:44Let's come back to our index file.
03:47Let's choose File > Save All just to make sure everything saved, and in the next
03:51movie we'll create our HTML file based on these CSS rules.
Collapse this transcript
Create, nest, and class DIV tags
00:00So in Dreamweaver's HTML file, let's come over to Code view.
00:04Now inside of the Code view inside of the body tag, I'm going to hit a few Returns.
00:09And as I was mentioning in the last movie, when we start typing inside of code
00:12view here, Dreamweaver is going to sort of help us code this, and it's even going
00:16to access the CSS rules that we've created.
00:17So let's start by creating our very first div.
00:22I'm going to type the beginning bracket, div, and hit space and type cl for class.
00:29Notice how this pop-up window is coming up and giving me access to everything
00:33that is available, either in HTML or in the CSS that's hooked in.
00:37So I am going to hit Return to type class, and then I see a dynamic listing of
00:41all of the classes I've created in my CSS document.
00:44I can use my arrow key down and come down to page_container. Hit Return.
00:51I'm going to hit an ending bracket to close the tag.
00:54I'm going to start a new tag hit a forward slash and Dreamweaver will automatically close
00:59that div tag for me.
01:01Now, I'm going to arrow back and get my cursor in between the beginning and
01:03ending div tags. I am going to hit a few Returns.
01:06This is going to be the overall container which is going to hold everything in our page.
01:11In the next line, I'm going to hit Tab, and let's create our first nested div.
01:18class=, this is going to be the gallery_credit and the tag.
01:26And inside of here, I'm just going to add the word text.
01:31That way when we switch to Design view, I can actually see where this div is and
01:35be able to get inside of it.
01:36Hit another Return, another div, class=, this is going to be the gallery_type and the tag, text.
01:56Now in the next line, these two divs are going to have float properties, so we
01:59want to clear out the float.
02:03class= clear_both. End that tag. Hit Return.
02:08Next, we're going to create the gallery_top. End that tag.
02:18gallery_content.
02:34Next, we'll create gallery_bottom.
02:35Then I'll close out the space on the ending div.
02:38So these are all of the main children that we're going to create under the
02:43page_container area.
02:44So now let's come into gallery_ content and let's open this up, and there is
02:49actually going to be children inside of gallery_content.
02:51This is going to be the middle area where we're going to have the stretching
02:54graphic defined inside the CSS, our tiling graphic we created in Photoshop.
02:59And this is going to hold our thumbnails and preview, caption and contact area.
03:04So inside of gallery_content, let's create a new div.
03:12This is going to be gallery_thumbnails.
03:16Let's end that div.
03:20Inside of gallery_thumbnails, let's open that up, and inside, let's type the word link.
03:25This is where we're going to put our thumbnail links.
03:27These links are actually going to be anchor tags that are going to have block
03:30properties assigned, and they are going to have float properties as well.
03:33So we're going to need to clear those.
03:39So we'll add our clear_both to clear all those,
03:42our float and anchor tags, once we have them in place.
03:44Let's come on the line after gallery_ thumbnails. Let's create a new div. This is
03:52going to be our gallery_preview. Let's end that.
04:00Let's open up gallery_preview, and inside there, let's just type the word img.
04:04Let's scroll down here a little bit.
04:07Now gallery_thumbnails and gallery_preview are going to be classes that are also
04:12going to float, so they're next to each other.
04:14Let's add a clear_both to clear the float on those two properties.
04:22Next, we're going to type gallery_ contact. This is going to contain our email
04:33address on the left side underneath all of the thumbnails.
04:36Let's create a new tag. This is going to be the caption. This is going to be
04:44floating on the right-hand side under the preview.
04:47Let's end that tag.
04:51Inside of each of these, let's just type the word 'text' so we can see them.
04:55Now these two items are also going to be floating, so let's clear those.
05:05Now, on the next line, we're going to add one more div, class=
05:16gallery_preload_area.
05:21Now, this particular class name doesn't exist in our CSS rules;
05:25however, we are going to log on to this class using jQuery, and this is where
05:29we're going to preload our images.
05:31Just like we saw in the introduction video, when we click a thumbnail, we will
05:34load an image into this area, preload it, and then when it's ready, we'll move the
05:38HTML to the main preview area and then fade up our content.
05:43So with this, this is the entire div structure and the order that we need to
05:47have all of our classes nested inside of each other to recreate our layout.
05:53Now in the next movie, we'll go back into our CSS rules and start to assign our
05:57graphics and styling for each one of these items.
Collapse this transcript
Adding CSS properties for main container
00:00Now, we want to apply CSS styles to the four divs that are inside of the
00:05gallery_content area, inside of that content div.
00:08So let's start by coming up to the thumbnails, gallery_thumbnails.
00:13Let's go to the Box properties. 500 pixels wide. Float left.
00:19We're going to set zero for all of the padding.
00:23Margin, we're going to set zero on the top, right, and bottom, and 40 pixels on the left.
00:27Now sometimes when I'm setting up my divs and setting up the layout I'll
00:32temporarily come in and set a Background-color so I can see them and see how
00:35wide the properties are.
00:37So temporarily, let's come in here and we'll just assign a color to the
00:41background of the thumbnails. Click Apply.
00:43Now I can see that Yellow bar here is representing the area for the thumbnails. Let's choose OK.
00:52Let's open up gallery_preview, Box properties for preview. I'm going to set 375
01:00on the Height and the Width.
01:01This is going to hold that preview-size jpeg.
01:03This is also going to float left. 0 for all margin and padding.
01:11Let's go to the Background-color and let's just temporarily set a color, so we
01:13can see this one. I'll choose Blue. Click Apply.
01:19Now I can see that div in place. Let's click OK.
01:24Just scroll down here a little bit.
01:26Now, let's open in gallery_contact.
01:30This is going to be the email address on the bottom-left, under all the thumbnails.
01:36Box properties, 477 wide, 60 pixels tall.
01:41This is also going to float left.
01:45For the padding, we're going to set 0 on the top, 23 on the right, 0 on the
01:50bottom, 0 on the left.
01:52So we want this to be 500 pixels total, and web browsers will add right and left
01:58padding to the overall width of the object,
02:00so 477 plus 23 gives us our 500.
02:04Uncheck Same for all for Margin, and we're going to set 0 on the Top, 0 on the
02:09Right, 0 on the Bottom, and the same 40 pixels on the Left for that as well.
02:14Background, let's just again temporarily pick a color so we can see that one. I'll choose green.
02:19Click Apply.
02:21I can see that box showing up here. Let's click OK and lastly, let's go to
02:26gallery_caption. I'll move this up over here.
02:31Box properties for that, we're going to set 375 on the Width.
02:34That's also going to float left.
02:36We're going to say 0 margin, 0 padding for all.
02:40Background, select violet.
02:48Click Apply. Choose OK.
02:52Now I can see the four divs we just created inside the content area:
02:55So the thumbnail is here in yellow.
02:57The image preview over here on the right.
03:00The contact area. And there's one thing I forget to set. Let's go back to contact
03:05real quick. Block properties,
03:07we want the text-align to be align right. Click OK.
03:11Now that I can see that all of my divs are in place and properly spaced out,
03:17I am going to quickly get rid of those backgrounds.
03:19The quickest way to do that would be to just jump over to the code. I'll scroll down
03:28to the rules that we just added.
03:29background-color for thumbnails, let's just delete that.
03:34gallery_preview background _color, let's delete that.
03:38gallery_contact, I'll delete that. And then lastly gallery_caption, delete that.
03:47Switch to HTML. At this point, let's choose File > Save All, and now we are ready to
03:56start creating the content that goes inside of these containers.
Collapse this transcript
Adding CSS properties for content area
00:00Now that we've completed our markup, let's switch over to Design view.
00:04In the CSS Styles panel, let's come over to .page_container and let's edit that rule.
00:09We're going to come down to Box properties.
00:11We're going to set this to 960. We're going to set 0 for all of the padding.
00:17For the margin, we're going to set 20 pixels on the top.
00:19We're going to set auto for right and left so this will center in the page
00:24and, 0 for the bottom.
00:25I can click Apply to see the changes take effect and then click OK.
00:32Next, we're going to edit .gallery_credit.
00:35This is the upper left-hand corner.
00:36This where we're going to have our name.
00:38Let's go under the Box settings here, and so for credit we're going to set a width of 425.
00:44We're going to set Float left.
00:45We're going to set 0 for all the padding.
00:49Margin, we're going to set 0 on the top, 0 on the right, 10 on the bottom, and 15 on the left.
00:56Click Apply. I can see that change take place. Click OK.
00:59Let's set the .gallery_type.
01:04Box properties for the type, 500 pixels wide.
01:08This will also float left.
01:09Padding, take off same for all, and set 4 the top, 0 for the right, bottom, and
01:15left. And for the margin, we're going to set 0 on the top, 0 on the right, 10 on
01:22the bottom, 0 on the left.
01:24Lastly, let's come over to the Block settings for here, and let's set
01:27Text-align to right.
01:31Click apply. Then we're going to say OK.
01:34Next, let's open .gallery-top.
01:38Box properties here, we're going to set a height of 20 pixels.
01:41We're going to set 0 for all margin, 0 for all padding.
01:47Background settings, let's click Browse.
01:49I'm going to come into our myGallery folder, into images, into template, click
01:57on page_top, that JPEG. Click Choose.
01:59We're going to set no repeat.
02:05We're going to set 0 on the X and Y coordinate. Click Apply.
02:09We can see that graphic pop into place. Let's click OK.
02:13Let's edit .gallery_content.
02:18Box properties in here,
02:19what we want to set is the padding.
02:22We're going to set 15 on the top, 0 on the right, at least 1 pixel on the bottom--
02:29this way the repeating graphic will actually touch the page bottom div--and 0 on the Left.
02:38Margin, we're going to leave all 0s.
02:39We're going to come over to Background.
02:41We're going Browse, select page_tile.
02:44This is going to be the graphic that's going to repeat vertically.
02:48On the repeat, we're going to say repeat on the Y axis, and we'll set a 0,
02:520 starting position. Click OK.
02:55Now let's come into .gallery_bottom.
03:00Box properties, set a height of 20, 0 margin, 0 padding.
03:07Background, choose Browse, page_bottom, click Choose, no repeat, 0 on the X and
03:16Y, click Apply, then say OK.
03:18Let's come in and create a new rule.
03:22I am going to create a tag.
03:24We want to assign the body tag. Let's click OK.
03:29Here we want to set the background. We want to set the background color to
03:34black. Choose Apply.
03:37Let's come over to our Type settings.
03:40Let's just set type default color to white.
03:43Let's set our default size to 0.75 ems.
03:49Our Font-family, we'll choose the Arial family set. Click Apply.
03:53Now I'll be able to see all the copy, and then let's click OK.
03:58Let's choose File > Save All.
03:59I am going to hit Option+F12 to preview this in a browser.
04:05Hit Reload, just to make sure the style sheets are in place.
04:08Let's open and close our window.
04:09I see that all of the gallery pieces are now centering inside that page content container.
04:14And we have the repeating graphic here opening up so that as we add more
04:17content in, this rounded corner box is going to stretch.
04:23At this point, we're ready to start styling the divs that are inside of the
04:26main container.
Collapse this transcript
Adding CSS properties for headings
00:01Now we're going to add the headings to our gallery.
00:03Let's start in the top-left here, inside of the div gallery_credit.
00:09So up here, we're going to type our name, select some of the characters,
00:13come down to Format.
00:14Let's assign this to be an h1 tag.
00:19In the upper-right, inside of gallery_type, I'm going to type Photography.
00:28Select a few characters here.
00:29Let's assign this to be an H2.
00:34With these in place, let's come over to our CSS panel.
00:36Let's create a new rule.
00:38The first one is going to be a tag, assigned to the h1. Click OK.
00:45First thing I want to do, come under the Box properties, set 0 for Padding and 0 for Margin.
00:52Let's come under Block properties, set Letter-spacing of 2 pixels. Come under Type.
01:00Let's set the Font to 1.75 ems.
01:02This will make this 75% larger than the base font.
01:08Color, we'll select white;
01:10Font-weight, normal; and then we'll click Apply. That looks right.
01:17Let's click OK.
01:18Let's come over to our CSS Rules.
01:20Let's create one more.
01:24Another tag defining the h2 properties. In here, Box model, first 0 for all
01:33Padding, 0 for all Margin.
01:36Block properties, we're going to set a letter spacing of 23 pixels. Let's go to Type.
01:44This is going to be 1.25 ems.
01:48Font is going to be medium gray.
01:49Weight is going to be normal.
01:52Text-transform, all uppercase. Click Apply.
01:56It's going to space this out here.
01:58Then we're going to click OK.
02:02Now that we have our headings formatted, we're going to start in the next movie
02:05by adding the thumbnail images to the thumbnail area.
Collapse this transcript
3. Adding and Linking Thumbnail Images
Adding and linking the thumbnail images
00:01Now, we're going to add some thumbnail images.
00:03Let's get your cursor inside of the gallery_thumbnails div, after the k, in that
00:07default text we put in there.
00:09Come up to the Insert panel > Insert Image > acrobats_thumbnail.jpg. Click Choose.
00:18Enter some Alternate text. Click OK.
00:21I am going to click on this and select it.
00:25Down on the Properties panel, I am going to come down to the Link area here and
00:28I am going to create a hyperlink around this image.
00:30So let's click on the little folder, and we want to link it to the
00:35acrobats_fullsize.jpg. Then click Choose.
00:40And when I click away, I can see this blue highlight around the outside, letting
00:43me know that this image actually contains a link to the high-resolution file. Let's test this.
00:51Choose File > Save All, and then Option+F12 or Alt+F12, Command+R or Ctrl+R to reload,
00:56and I can see my gallery here.
01:00Let's roll over the thumbnail.
01:01I get a little pointer. I click it,
01:03and it links me over to the full-sized JPEG.
01:05Then I can use the browser's Back button to go back.
01:07Now, in the introduction video, we talked about the fact we were going to
01:11progressively enhance this user experience.
01:14So in the base part of the design, we're going to build thumbnails that are just
01:17going to simply link to their high-resolution files.
01:21By using JavaScript and jQuery, we're going to intercept that basic behavior and
01:26add preview links and initiate lightboxes and do all this extra stuff that will
01:30only be supported if the browser supports these more advanced techniques.
01:34This base technique here will work all the way back in really early browsers
01:38and even on mobile phones that have crippled or non-fully enabled web browsers on them.
01:45So in here, let's close the browser.
01:46Let's come back to Dreamweaver.
01:47Let's switch over to Code view.
01:50Inside of Code view, we have, inside of gallery_thumbnails, we have our first
01:55anchor tag with the image inside of it.
01:58Let's delete that link text, and we want to add one more piece of code in here.
02:02We want to add a title attribute to the anchor tag.
02:07Titles are what actually show up on a hyperlink if you roll over it,
02:10so we're going to use this to create our captions.
02:12And I am just going to type 'Caption goes here for Acrobats'.
02:22So at this point, we need to add the remaining 19 thumbnail images and link each
02:26corresponding thumbnail to its high-resolution file.
02:29I'll do that before the next movie, and then we'll continue on.
Collapse this transcript
Styling the thumbnail links with CSS
00:00Now, before this movie, I've set up the additional 19 thumbnails. Just drag them
00:04inside of Dreamweaver, following the process we looked at in the last movie and
00:07then linking each one to the full size,
00:09and then in addition, adding a custom caption into each one that just includes
00:13the file name somewhere.
00:14This way we can actually check in jQuery to make sure that the caption we're
00:17going to pull out of here gets populated into the caption area properly.
00:21Now, you can change the order of the images by simply changing the order of the
00:25anchor tags inside of here.
00:27And if I switch to Design view, this is what we're looking at.
00:31Now, in here I'm going to choose File > Save All and then Option+F12 or Alt+F12 to
00:34take a look at this in our default browser. Hit Reload.
00:38Now, Safari is showing me these images here without a border around the outside.
00:43But if I take the same file, go back to Dreamweaver--
00:46let's preview this in Firefox--
00:48Firefox will actually show me the blue border of the hyperlink around
00:52the individual images.
00:53Internet Explorer will do the same thing.
00:56So what we want to do is let's close our two browsers, come back to Dreamweaver,
00:59go into the CSS Styles panel.
01:02Let's create a new rule.
01:03It will be a compound rule.
01:05We're going to type 'a img'.
01:08We're going to target image tags only if they're inside of anchor tags, and what
01:12we want to do is come into the Border settings. On Same for all, we're going to
01:18set None for style, so there will be no border assignments on images that are
01:22inside of anchor tags. We'll click OK.
01:27We'll choose File > Save All.
01:29Let's go look at this in Firefox one more time. And now Firefox will show me
01:33these without the borders around the outside.
01:35Now, each one of these items will link properly, so I can click these and go to
01:40each high-res image.
01:42Click the Back button.
01:43So now that the functionality is in place, let's go style the thumbnails.
01:47Let's close our browser. Let's go back to Dreamweaver.
01:50Let's come over to our CSS Rules.
01:52I'm going to create a compound rule.
01:54Now, one of the nice things about Dreamweaver is, when we have our cursor inside
01:58of an area and we click Compound Rule here,
02:01it will attempt to build a compound rule for us. And we actually do want a
02:05target inside of gallery_thumbnails, so I'm going to delete all of this text
02:08here. Or I could simply click More or Less Specific to take out the full path of
02:14all of the nested classes.
02:16So gallery-thumbnails, we're going to do ' a'. We're going to target the anchor tags.
02:21We're going to click OK.
02:22One of the first things I'm going to do is come under the Block properties, set
02:27the Display to block.
02:29Anchor tags by default have a display style of inline.
02:32We're going to change that to block.
02:33Let's come under the Box settings.
02:36We're going to set these to 75 x 75 pixels.
02:39We're going to set Float left.
02:41I'm going to go to Border. Under Same for all, we're going to click Solid, 1 pixel.
02:50We're going to pick the same medium gray that matches the border of our design.
02:56Lastly, let's go to the Box properties.
02:58We'll set 0 for all of the padding.
03:02For the Margin, we're going to set 0 on the Top, 23 pixels on the Right, 23 on
03:07the Bottom, and 0 on the Left.
03:11Now when I click Apply, this will space these out, so now each thumbnail will
03:15have no other thumbnails within 23 pixels of its right and bottom, and that
03:19will space the cell to give us exactly five across and four rows down, equaling
03:23our full 20 thumbnails. Let's click OK.
03:30Let's create another rule, another compound rule.
03:35Click Less Specific, gallery_thumbnails a: hover.
03:39We'll add a pseudo-class to these, so when we hover over these, we want to simply
03:45come in, change the border to white, click OK.
03:51We can test this by clicking Live view or Preview in Browser.
03:57Now when I roll over these, the border turns white.
03:59And let's create one more class.
04:04This is going to be the selected state. So whichever photo we happen to be
04:09looking at in jQuery, we're going to add this class.
04:12So I'm going to type a.selected, so any anchor tags inside of gallery_thumbnails
04:19that also have a class on them, I've selected.
04:21We're going to come in here, do the same thing in the border.
04:25We're just going to set that to be white.
04:26We're also going to set the photo inside to be semitransparent, but that's a
04:30function we're going to add in jQuery.
04:31Then we'll click OK.
04:34Now to test this, I'm going to come out of Live view.
04:36I'll click on one of these images, down here in Dreamweaver's document tree.
04:41I'll click on the a for the anchor tag. Click on Class.
04:46Let's select Selected. Let's click away.
04:49Let's go back into Live view, and I can see that this one is now in its selected
04:53state because the border is not white. So that works.
04:58Let's take that off.
05:06Let's choose Save All.
05:07So now that we're done formatting our thumbnail links, the next step is to add
05:12some JavaScript and jQuery to our project.
Collapse this transcript
Downloading and adding jQuery to your project
00:00Now that all of our thumbnails are in place, I want to make one quick change.
00:04I want to go into Code view and I actually want the refraction photo to be the
00:07first one to show up.
00:08So as I had mentioned earlier, you can change the order of the gallery items by
00:12simply changing the order of the links.
00:14So I'm going to cut and paste the refraction link and the refraction thumbnail
00:19to be before the acrobats picture.
00:21So now when I come back out to Design view, that's the first one that they'll see.
00:25And at this point, we're ready to add some jQuery into our project.
00:29So let's open up a web browser.
00:31Let's go to jquery.com. Over here on the far right side is a big button
00:36that says Download jQuery.
00:37I'm going to click on this.
00:40Some browsers will actually start a download right away;
00:42some, like Safari, will actually show you this code. But again, we can see up in
00:46URL here that this points to the .js file.
00:49So I can simply come down and say File > Save As, pick our includes directory
00:56inside of our myGallery folder, keep the file name that they write by default,
01:02and let's close our browser.
01:03So now back in our operating system, I can see in the includes directory I now
01:07have a copy of jQuery in addition to our gallery.css.
01:10Let's come back to Dreamweaver.
01:13Let's choose File > New, and let's create our own JavaScript file.
01:16Select JavaScript from the Page Type, click Create, File > Save in the includes
01:23directory, gallery.js.
01:26This is going to be the file where we'll rewrite our custom JavaScript to hook onto
01:33jQuery to change the user experience in the index file.
01:35Let's come back to Index.
01:38Let's switch to Code view. We'll scroll up to the top.
01:42Let's get the cursor after the CSS reference. Hit Return.
01:46I'm going to come up to the Common insert panel. On the far right, I'm going to come
01:51over here and click insert a script.
01:56Click Browse, pick the source.
01:58First, we need to bring in our jQuery file. Click OK. Hit Return.
02:05Let's bring in our second script.
02:07This is going to be our custom gallery.js file. Then click Choose. Then say OK.
02:13So since our JavaScript file that we are writing has to hook onto jQuery, jQuery
02:17has to be imported first, then our gallery.js file.
02:23Switch back to Design view, and I can see the related files at the top here in
02:26Dreamweaver, letting me know that this html file includes gallery.css, jQuery
02:31min.js, and gallery.js.
02:36At this point, we're ready to start writing some custom JavaScript, and we'll
02:39start that in the next movie.
Collapse this transcript
Overriding the browser's default link behavior
00:00Now, I am going to want to edit my JavaScript file in a separate window, in a
00:04separate text editor, so we can see Dreamweaver in the background.
00:06So I am going to close that.
00:08In the index file, I am going to switch over to Code view.
00:11I am going to move my anchor tag code up here to the very top, so I can see it.
00:16I am going to switch back out into my OS, and I am going to open gallery.js
00:21in the text editor.
00:24My text editor of choice is Coda, and you can edit this JavaScript file in any
00:29HTML editor, or in Dreamweaver.
00:31So, I want to edit my script in a separate window in a separate application, so
00:36I can see the code in the background of what I'm actually going to be targeting
00:39with my JavaScript and jQuery statements.
00:42So, inside of our JavaScript document, let's start by adding our document ready function.
00:45We will start with a Dollar sign, which is jQuery's way of initiating the functions in
00:50the jQuery file we downloaded.
00:52Type document. Outside of the parentheses, we will type ready.
01:01Beginning and ending parentheses, semicolon.
01:03Inside the ready, we're going to type function, beginning and ending parentheses,
01:11beginning and ending bracket.
01:12Then we are going to split the brackets.
01:16Anything happening inside of here is going to run after jQuery has downloaded
01:20all of the HTML code in the page.
01:22So, the first thing we want to do is start by targeting all of the anchor tags
01:27that are inside of the gallery thumbnails div.
01:30Start with the Dollar sign, beginning and ending parentheses, two tick marks
01:35for string literal.
01:36I am going to type gallery_thumbnails space a, come outside of the parentheses
01:48.click, beginning and ending parentheses here, semicolon.
01:55Now, we are adding a click event to all of the anchor tags.
01:59Inside of here, we are going to type function, beginning and ending parentheses.
02:05Inside of the parentheses, we are going to put a lowercase e.
02:07This is going to capture the event that actually started the click.
02:14Beginning and ending bracket and let's split this function.
02:21The first instruction inside of the function on the click event for every one of
02:24the anchor tags, we are going to type e.preventDefault, beginning and ending
02:32parentheses, and a semicolon.
02:35This tells the browser to ignore the default behavior that it would do on an
02:39anchor link, which in this case so far has been when we click on a thumbnail,
02:42the entire page shifts over to the high-resolution thumbnail.
02:45So we are going to tell the browser to not do its basic function on an anchor tag.
02:52And then what we want to do is let's set the states of the thumbnails.
02:55So, let's start by copying the statement, come down here, Command+V or Ctrl+V to
03:03paste, so gallery_thumbnails a. We are going to go through all of these.
03:08I am going to type 'removeClass' and put a string literal inside of the
03:20parentheses, called selected.
03:21We are going to make sure that none of the anchor tags have the selected
03:24class assigned to them.
03:25On the next line, let's paste that same statement again.
03:28We are going to say all of the anchor tags .children.CSS, beginning and ending
03:40parentheses, semicolon.
03:43Inside of here, we are going to do one string literal.
03:45We are going to type 'opacity' then a comma, then a second string literal and the number 1.
03:54So, we are basically going to add CSS properties to all of the thumbnails,
04:00setting the children, the image tag inside of the anchor tag, with an opacity of 1.
04:07Add a few more lines. Then we are going to say Dollar sign parentheses, this, which is whatever the item is
04:14that was actually clicked on.
04:15We are going to say addClass, string literal, selected, and hit Return, Dollar sign
04:30this .Children.CSS, beginning and ending parentheses, semicolon, two tick marks
04:44for string literal opacity, two tick marks .4, for 40% opacity.
04:52Let's say File > Save.
04:55Let's make sure all of our files are saved in Dreamweaver. Choose Save All.
05:01Then we are going to come out to the OS. We are going to grab this index file
05:05and open it up in a browser. Hit Reload.
05:08Now, when I roll over these items, I see the rollover state.
05:12When I click on them, whatever item I click on, the border turns white from the
05:17selected class we created earlier, and the image inside gets 40% transparent.
05:23Now, with our thumbnails fully functional, let's start on the preview area.
Collapse this transcript
4. Incorporating the Preview Images
Creating preview images from anchor links
00:00Now, the preview photo area over on the right-hand side is going to be anchor links.
00:04We are going to have just anchor links in that right side. We are going to set
00:08the background image to be the preview JPEG, but we are going to put that in
00:12through an inline style.
00:13So, I am going to start by getting rid of the img text over here in the image
00:18preview, and then we are going to create CCS rules in order to style these.
00:25Let's come over and create a new CSS rule, Compound selection, choose Less Specific.
00:33We are going to do gallery_preview, space a, any anchor links inside of there. Let's choose OK.
00:45Box properties: 375 x 375.
00:50We are going to say 0 margin and padding.
00:52We are going to come over to the Block settings.
00:56Since we are going to be putting anchor links in here, those have a display type of inline.
01:00Let's change that to block.
01:04And lastly, let's come over to the Border.
01:05We are going to select a solid, 1-pixel, medium gray border.
01:12Then we are going to click OK.
01:16We'll create one more, .gallery_ preview a:hover.
01:26What happens when we roll over the anchor links on the right? Let's click OK.
01:35Border, we are going to set the color to white. Click OK.
01:39Now that we have our CSS rules in place for the anchor links, we are going to
01:44put in the preview area.
01:45In the next movie, we are going to start by creating anchor links in the preview
01:49area, based on the thumbnail you clicked on the left-hand side.
Collapse this transcript
Changing the preview when clicking thumbnails
00:00Now that we have our preview links set up in our CSS, let's come over to
00:04our JavaScript file.
00:06So now what we want to do is create those anchor links based on the image
00:10thumbnail that was already selected.
00:12So, let's add a few lines into our JavaScript file, and the first thing we are going
00:16to do is set up a few variables.
00:17We are going to type 'var photo_caption', and that's going to equal Dollar sign,
00:28this .attr, semicolon,
00:37and then inside there a string literal, title.
00:42So, whichever anchor link we actually clicked on, we are going to pull into a
00:45new variable called photo_caption the title attribute of that object. That's
00:48going to give us our caption.
00:51var photo_fullsize.
00:55It's going to be equal Dollar sign this .attr, and in here we are going to put href,
01:10the actual link destination of full size, because we took the thumbnail images
01:14and actually linked them to the high-resolution full-size image.
01:18That's where that variable is going to set up.
01:21Then lastly, photo_preview.
01:26Now, photo_preview would never use the term preview.jpg. So right now in our
01:32HTML, there is no way for the browser to know we specifically will have another
01:37file size here called preview.
01:38So, what we are going to do is concatenate this by string replacing the file
01:43name fullsize with the file name preview.
01:45So, in order to do that, we are going to grab photo_fullsize, copy this, so
01:51photo_preview is going to equal photo_ fullsize.replace, beginning and ending
01:58parentheses, semicolon.
02:00Now, this is not a jQuery function. This is a straight JavaScript function.
02:03We are going to put inside of replace two tick marks for string literal,
02:10fullsize, comma, two more ticks for another string literal, preview.
02:16So, this is very similar to what we did in Bridge when we were doing our grep
02:21search for our file name replacement.
02:23So, we are basically coming in here and saying photo_preview is going to equal
02:27the full-size variable, which we got from this line here and is going to search
02:31for fullsize and replace it with _preview.
02:35That's going to give us the URL to the preview image.
02:41Now, on the next line, we are going to actually write the HTML into the page.
02:44Dollar sign, tick mark, gallery_preview.html, beginning and ending
02:57parentheses, semicolon.
02:58Inside of the HTML tag, we are going to put two tick marks for string literal,
03:05and we are actually going to write the anchor tag we are going to create.
03:08So, beginning tag a space href =. I am going to put to two full quote marks.
03:15I am going to end the tag and then end a tag.
03:22Inside the href, I am going to put an x for the moment.
03:26Let's add another attribute, title equals two quotes, another x, style equals
03:36background-image:url beginning and ending parentheses, semicolon, and let's put
03:50an x inside there as well.
03:52Now in places in this string literal where we have Xs, we are going to replace
03:56these with the variables.
03:57So, let's start with photo_caption. Let's grab this and copy to the clipboard.
04:01Let's come down to title.
04:04Let's delete the x. Let's put two single tick marks, two Plus signs, and then
04:11let's paste the variable inside of there.
04:13So, what happens here is we get a concatenation of the string literal and the
04:18variables that we set.
04:20So, the first part of the statement comes right up to the two tick marks here.
04:24Then JavaScript we will replace in photo_caption, and then we will get the
04:28rest of the statement.
04:29So, for the href, we want to take photo_fullsize, copy that, two tick marks, two
04:39Plus signs, paste that in.
04:41That means that the preview image is going to actually link to the full-size image.
04:46So, instead of the thumbnails linking there, we have prevented that default;
04:49instead, we are going to have the preview anchor link to show the image in the background.
04:53Then later on, we are actually going to add the lightbox link to this as well.
04:57Then lastly, let's come over and grab photo_preview.
05:00This is the preview JPEG url.
05:03Let's come over to the x in the image url, two ticks, two Plus signs.
05:10Then we will paste that in.
05:11Let's choose File > Save.
05:16Let's make all of our files inside of Dreamweaver are saved. Choose File > Save All.
05:23Let's come back to our operating system.
05:23Let's grab the index.html file, double-click it, Command+R or Ctrl+R to reload.
05:32And now when I click on each of these images, I see that the image will
05:38actually update over on the right-hand side.
05:40Again, this is just an anchor link with the background style. And of course, if
05:44I roll over it, we can see the pop- up window coming in for the title.
05:53So, that works great!
05:54In the next movie, we are we are going to actually pick up the caption, and we
05:56will populate the caption to go along with the photo.
Collapse this transcript
Changing the caption when clicking thumbnails
00:00Inside our Click function for all of the images, I want to add a second
00:04statement, and we are going to update HTML that's part of the gallery caption as well.
00:10So let's start off with a Dollar sign, string literal 'gallery_caption.html', beginning
00:22and ending parentheses, semicolon.
00:25Inside here, let's start our string literal.
00:26Let's start off with a beginning and ending P tag.
00:30Inside of our paragraph tag, the first thing we are going to add is going to be an anchor tag.
00:35Let's end the anchor tag, set an href attribute inside, open the letter x in
00:46there. And in here, we are actually going to say View larger.
00:52Come after the P tag.
00:57Let's start a new p tag and an ending p tag. And inside of here, we are going to
01:04put a letter x. Now back in our href tag, let's add in title attribute, two
01:12quotes and the letter x. Now are going to come in here and replace these with the
01:17actual variables. So the href, this is going to be a text link which will also
01:22link to the full-size preview, and we will add classes later to initiate the
01:26lightbox function on that.
01:27Command+C or Ctrl+C to copy the variable, photo_fullsize.
01:33href, two tick marks, two Plus signs, paste.
01:40The caption, we are going to grab this.
01:42We are also going to put this in this anchor tag, two tick marks, two Plus signs, paste.
01:50The lightbox functionality actually pulls the title attribute from the anchor
01:53link and puts the caption in the overlay as well, since we need to actually pass
01:57that along to the large image that's showing up in the lightbox.
02:02Now, we have photo_caption on the clipboard.
02:04Let's come over to the x here, two tick marks, two Plus signs, paste.
02:11Let's choose File > Save.
02:12Let's go back to the operating system.
02:14Let's open this up in our browser, hit reload, and now each I click these links, we
02:22get a View larger link, so this actually links to swatches full size.
02:25If I click this, it links to that full-size image. Here's my browser's back button.
02:31888, rose, lantern, then the caption and again, the link is updating to lantern as well.
02:39So at this point, we are dynamically generating anchor links of the main preview
02:44image, which I can click to go to full size,
02:47we are generating a text-based link going to the same destination, and we are
02:51pulling out the caption data from the title attribute of the original thumbnail
02:56that we clicked on and populating the text down here as well.
02:59What we need to work on now is to set up our preload.
03:03We are actually going to use a jQuery plug-in called far IN space Image Preloader
03:07to preload the images so that when we fade the images up and down, we make sure
03:11that the image has been downloaded first before we do that special effect.
03:15So in the next movie, we are going to start by adding a plug-in to help us
03:17to preload images.
Collapse this transcript
5. Adding a Preloader
Adding an image preload plug-in for jQuery
00:01Now, when we first started our JavaScript file and hooking jQuery into here, we
00:05used this feature called the document ready.
00:07But the document ready makes sure that all scripts and all HTML and text are
00:12downloaded from a particular web page.
00:15What it doesn't do is download images.
00:17There are a few ways that we can actually preload images.
00:20There's lot of free plug-ins up on line. So the one that I really like is
00:24one called far IN space.
00:26So in the Final Project folder, in the include, there is a directory called
00:29farinspace. And there is a README file in here, and the README file will give
00:34you a link to the web site where you can download a copy of this.
00:37You can also read about its usage.
00:39What I really like about this is it is a plug-in, so that means we simply link to
00:44one JavaScript file and we can use a very simple statement, such as .image
00:50preload, point to an image or a div containing images, and this script will
00:55automatically preload all the images that it sees, and when it's done, it can
00:59give us a callback function to tell us that they are all preloaded.
01:01So I am going to close this in the browser. So I am simply going to grab the farinspace,
01:10I am going to grab the whole folder, and I am just going to drag a copy over to
01:13our includes directory in our project.
01:15Once I have done that, let's come over to Dreamweaver.
01:19Let's go to the main index page.
01:22Let's go into Code view.
01:23Let's scroll to the top.
01:24Now, this is a jQuery plug-in, so we are going to insert this after the jQuery
01:32statement but before our JavaScript statement, since our JavaScript is now
01:35going to require jQuery and the image preload.
01:39Let's come up to Common.
01:41Let's choose Insert Script.
01:43Let's go to our myGallery folder > includes > farinspace.
01:49We will grab imgpreload.js.
01:53Actually, I am going to grab the minified version.
01:55It's a little bit smaller.
01:57Click Choose and say OK.
01:59Switch back to Design view. File > Save All.
02:04Now that we have the preload image in place, I want to add a special effect so
02:09that every time you click an image, I want to fade up the picture. But the
02:13picture can only fade up if it's already been downloaded,
02:16so we are going to add in the preloader, then add in the special effects as
02:19well, and we will start all that in the next movie.
Collapse this transcript
Setting a dissolve transition between previews
00:00Now that we've added our image preload plug-in, let's come over to
00:03our JavaScript file. I'm going to open this window a little bit more, as our script gets taller.
00:11I am just going to get rid of some of the extra line spaces here.
00:16I'm also going to add in a few comments.
00:18This group of four statements here, this actually changes the thumbnail state.
00:22So we will just put a comment, two forward slashes, update thumbnails.
00:34These are going to be set up vars from thumbnail.
00:44Then down here, these two statements we made earlier, the update preview
00:48and gallery_caption,
00:49we are actually going to use these inside of another function.
00:52I am going to save my document so far, and let's come in here. And the first thing
00:58we want to do, once we click on of these functions--and remember we are still
01:02working inside of the anchor tag clickEvent--
01:06the first thing we are going to do, add a Dollar sign, beginning and ending parentheses,
01:11two tick marks, .gallery_caption.
01:16We are going to take the caption div.
01:19We are going to use jQuery slideUp.
01:26This is going to animate the caption upward, because once we click on an item, we
01:30want to caption to fade away.
01:32Another line, Dollar sign, beginning and ending parentheses, two tick marks, string literal.
01:39We are going to say gallery_preview, fadeOut, beginning and ending parentheses, semicolon.
01:51500 ticks in there as well.
01:55So when we click it, the caption will slide up. The gallery preview area,
02:00the area holding the anchor tag with the image in the background, will now fade out.
02:03Now inside of fadeOut, I am going to get my cursor after the 500.
02:07I am going to put a comma, space, add a function, beginning and ending
02:14parentheses, beginning and ending bracket.
02:17By putting this function inside of this fadeOut function here, this is going to
02:20happen on what we call a callback. So once the animation has faded out over half
02:25a second, it's going to run this function.
02:28Let's put that on the brackets.
02:30So inside of here is what's going to happen after the fade-out occurs.
02:35So once the fade-out occurs what we are going to do is come down, grab the two
02:40statements down here,
02:41we are going to cut these to the clipboard and paste them up here.
02:44So we are going to set the gallery image preview of the HTML to the new photo
02:52size based on the variables we set up in the vars up here. Then we are going to
02:57set the gallery_caption as well.
03:00Once that's happened, we are going to fade the gallery back up. So let's come
03:05over here, grab gallery_preview, copy to the clipboard, paste it down here.
03:11I will type fadeIn, over half a second, add a new line, gallery_caption,
03:27slideDown, which is going to show this content, beginning and ending
03:32parentheses, semicolon, 500 ticks inside of there.
03:39Let's choose File > Save.
03:40This should create the animation that we were looking for, click a link, slide
03:44up the caption, fade out the preview, switch the HTML for both preview and
03:48caption, and then fade up the preview and slide down the caption.
03:52Let's come out to the operating system.
03:53Let's double-click the index file, Command+R or Ctrl+R to reload, click on an
03:59item. And if you are looking at the caption area, each time I click, the caption
04:07slides up, changes, and fades back down-- or slides down, rather, and the image
04:12fades out. We switch the HTML and the image fades back up.
04:15Now that this behavior is working as we want,
04:20in the next movie we are going to add preload into this script, so that when we
04:23click on a thumbnail we will preload the preview image first and then fade it up
04:27to make sure that it's fully loaded and we get a nice smooth transition.
Collapse this transcript
Implementing the preload functionality
00:01Now to add our preload check into here, the first thing we need to do is pick a
00:05place to put the image so that we can perform the preload.
00:09So back in Dreamweaver, back in Code view, when we were first setting up our div
00:13structure, we created this class in here called gallery_preload_area.
00:16I am going to copy the name of this class to the clipboard.
00:20I am going to switch back over to our JavaScript file, and what we're going to do
00:26is that we want to run the preload after the fadeOut is happened.
00:29So we're actually going to come in here, add a few lines,
00:33I am going to put a Dollar sign, beginning and ending parentheses, two tick
00:39marks for string literal, dot and then Command+V or Ctrl+V for paste,
00:45gallery_preload_area.
00:46We're going to set the HTML, beginning and ending parentheses, a semicolon.
00:52Inside of here, we are going to set a string literal, image, source, equals, two
00:59quotes, forward slash, end bracket. And inside there, we're going to put a letter x.
01:04So what we're going to do is take the preload area and put an image tag in that area.
01:12Let's grab photo_preview variable, select the X, hit Delete, two tick marks, two Plus signs.
01:20We're going to concatenate the string, photo_preview.
01:27On the next line, I am going to copy the declaration, picking that div.
01:35So we're going to say Dollar sign, .gallery_ preload_area img, so we are going to target
01:40all images that are inside the preload area, which we just added one on the line above.
01:45Now, we're going to use imgpreload.
01:52This is the name of the actual function
01:53that's part of the far In image preload tool. Beginning and ending
01:58parentheses, then a semicolon.
02:01So this statement, this is the name of the plug-in.
02:03So once we hooked in the farinspace into our page, we can call this just like any
02:07other function and this will actually perform a preload on all of the images
02:12that are inside of preload area.
02:16Inside of here, let's add a function, beginning and ending parentheses,
02:21beginning and ending bracket.
02:24This function is callback function, and it's only going to run after all the
02:27preload has happened.
02:28So let's open this up a little bit.
02:31So these are all of the things we want to have happen only after the preload has taken place.
02:36So, let's cut all this to the clipboard, put our cursor inside here, and let's
02:42paste all of this inside here.
02:43I will tab some of this in, so we can see the structure.
02:47So now when our full script happens, the anchor tags get clicked. We prevent the default.
02:55We set the states of the thumbnails.
02:57We defined variables based on the thumbnail you clicked, which is this statement.
03:01We created a photo_preview URL because we don't actually use that in our HTML.
03:06We set the gallery_caption to slide up, we fade out the picture. Then we take the
03:12preload area, we put an image tag in it, then we run a preload on that to make
03:16sure that's been loaded. Then we update the HTML for the preview, update the
03:20HTML for the caption, and then we show the preview and show the caption.
03:24Let's hit File > Save. Let's come out to our operating system.
03:27Let's double-click index.html, Command or Ctrl to reload.
03:33Now when I click on these images, the preload will happen and the type will fade up.
03:38Now, open this window up a little bit, and if we put this up on a web server
03:43where we have maybe a little bit of a slower Internet connection, or we put a
03:46really heavy preview file, a file with a big file size, we will actually see
03:50the preload happening.
03:52But also notice down here I have the image preload area, which is where the first
03:56image tag is getting written.
03:57So as I click these, notice that on the right-hand side when the image fades out,
04:01we see the picture down below switch, and then we get the fade-up.
04:04So now what we need to do is set a CSS rule that hides that particular div.
04:13Let's come back over to Dreamweaver.
04:17Let's create a new CSS rule.
04:19This is going to be a class.
04:20We're going to set .gallery_preload_ area, click OK, Block properties, set the
04:34Display to None--we don't want the user to ever see that.
04:39Let's choose File > Save All.
04:40Let's go back to our browser.
04:43We will hit Reload.
04:46Now, I can click on the images. The image will get written into that area we
04:51just set to be hidden with CSS, the preload happens, and then the content will fade back up.
04:56Now that our preload is working, now we want to add in our lightbox plug-in and
05:04set our overlay links.
Collapse this transcript
6. Adding a Lightbox
Adding a lightbox plug-in for jQuery
00:01At this point, we are ready to add in a lightbox functionality.
00:03So the one I really like and I've included in the exercise files is Fancybox.
00:10To learn more about Fancybox, you can visit their web site, fancybox.net.
00:13You can download the latest copy of this particular plug-in, and this works
00:17exactly the same way as the preload works, where we hook in our files and
00:21then we simply can make calls called Fancybox just like regular functions inside of jQuery.
00:25So I am going to take the Fancybox folder in the includes directory from
00:31Exercise Files and we are going to move this over into our project.
00:37Once this is here, let's come back to Dreamweaver.
00:39Let's go to our index file.
00:41Let's go to source code.
00:42We're going to get our cursor after the preload JavaScript.
00:49It can go before or after that;
00:50it needs to come after the jQuery include and before our custom js file.
00:56So up here, I am going to choose common, insert script, I am going to go to the
01:02desktop, my gallery, includes, jquery.fancybox, go into the fancybox folder.
01:11Down here at the bottom, I will open this window up more.
01:13We are going to click on fancybox-1.3.4.js. Click Choose. Click OK.
01:21Let's hit another Return.
01:25Now we need to import a CSS file, come up to Format > CSS Styles > Attach Style
01:31Sheet, Browse > myGallery > includes > jquery.fancybox > fancybox folder, and we will
01:40grab the fancybox-1.3.4.css and click Choose and say OK.
01:48Switch back out to Design view.
01:50I can now see the Fancybox, related files showing up here on the top of
01:53Dreamweaver as well.
01:54Now in the next movie, we're going to set up some jQuery statements to activate
01:58hyperlinks to load high-res images in the lightbox.
Collapse this transcript
Creating a custom function for lightbox properties
00:00Now, the way Fancybox works to initiate links into the lightbox is to simply add
00:05classes on anchor tags and then set up a jQuery statement that looks for those
00:09anchor tags with specific classes.
00:11If I go into the includes directory, into Fancybox, they've included an index.html file.
00:16If I double-click this, this will give me a bunch of different examples on
00:20different ways the Lightbox can work.
00:22This one here just simply fades up and down.
00:24This one here runs an elastic animation up and down, giving us that zoom effect.
00:30This one just sort of pops on and pops off.
00:33We can also do different things with the captions.
00:35We can have captions show up underneath.
00:36We can have captions show up inside the border. And the one I like, the last one
00:41here, I can actually have the text show up inside a semi-transparent overlay.
00:47And in order to see how all of these are coded, we can take that index file and
00:51open it up in either a text editor or Dreamweaver.
00:54So at the very top here, I can see here are the different examples, and lower in
01:00the code, we can see how they are executed.
01:02So this is an anchor tag with an ID of example 1.
01:06So example 1 is the one that just simply fades up and fades down.
01:09I'll come up to the top of the document. I'll look for example 1, which is right
01:13here, and that's just the simple Fancybox statement.
01:18Other ones here have a bunch of different settings: overlay, transitionIn,
01:21transitionOut, opacity settings, positioning for the captions, a whole bunch of
01:27different formats--and of course, the web site documents all of these
01:30different switches.
01:31So what we're going to do is go into our JavaScript file, and one of the things
01:36that we'll also need to do is typically we assign the anchor tags to be paid
01:41attention to by Fancybox by putting it in the document ready.
01:44However, since we are going to be pulling HTML from one spot and
01:48concatenating the data into the caption area, we need to be able to
01:53reinitiate all of the links.
01:55So what we're going to do is create a brand-new function outside of the document
01:59ready in our JavaScript file and run the Update Overlay links any time we're
02:05going to make a change.
02:06So we're going to start by coming to the bottom of the document here outside of
02:11the document ready, and we're going to create our own custom function.
02:14I am going to type 'function', and we're going to call this setFancyboxLinks.
02:26That's the name of the function.
02:27We can name this anything we want. Beginning and ending parentheses,
02:32beginning and ending bracket.
02:33I am going to hit a few returns.
02:36Now inside of here, I am going to tab in.
02:40We're going to make a jQuery statement, Dollar sign, beginning and ending
02:44parentheses, two tick marks for string literal, a.overlayLink, come outside of
02:55here, .fancybox, beginning and ending parentheses, then a semicolon.
03:04Then inside this function, we're simply going to put just two brackets--
03:07beginning and ending.
03:08We're going to split that open.
03:11Let's come inside here, and let's set some of the parameters.
03:14I am going to do two tick marks for a string literal.
03:19We're going to do titlePosition, space, colon, another string literal, the word
03:28over, this will place the text over top of the overlay. Let's tab in.
03:33This is going to be 'overlayColor', colon, string literal, '#000'--that's black.
03:44Next line, string literal 'overlayOpacity' : 0.8, 80%, put a comma. Next line, type
04:03'transitionOut', string literal, 'elastic', comma. Next line, 'transitionIn'. I just realized I
04:19spelled the first transition incorrectly.
04:20'transitionIn', also 'elastic', then a comma. The last line we're going to turn 'autoScale': to true.
04:40Now in the last one, we don't need a comma because these are paired values, but
04:44the very last one doesn't need a comma because there's nothing that's going to
04:46be repeating after that.
04:49So now this function, setFancyboxLinks, is going to run.
04:52It's going to find every anchor tag with the overlay link class assigned to it,
04:56and it's going to activate it as a Fancybox link.
04:58So now we need to actually initiate this function.
05:01So let's copy this. Let's scroll up.
05:07Let's come up here into the area where we are preloading the image and then
05:10setting all of the content inside both the preview and the caption.
05:13So let's come in here after we say gallery_preview.fadeIn,
05:17gallery_caption.fadeIn.
05:19Let's add another line. Then we're simply going to put setFancyboxLinks with the
05:26beginning and ending parentheses and a semicolon.
05:28This is going to call this function.
05:30Now the last thing I need to do, let's come down and select overlay link.
05:35Let's copy that to the clipboard, Command+C or Ctrl+C, and we need to come up here
05:40and add this class into these two links.
05:43So this first one here, gallery_preview, let's put a space inside the anchor
05:47tag, class equals, two quotes, paste in overlay link. And then down here, we have
05:54our text base link which says view larger.
05:56Let's add the same class in here, class="overlayLink".
06:02So now these two anchor tags are going to get dynamically written in.
06:07Then we're going to fade up all the content. Then we're going to run the setFancybox function.
06:11This function is going to then go back through the document, look for every anchor
06:15tag with overlay link, and it's going to find these two that we just created,
06:18and then it's just going to activate these on click to overlay the image and
06:22it's going to link it to the full-size photo, which is the href of the original anchor tag.
06:27In addition, the caption is going to come from the title tag in the anchor tag.
06:32Let's choose File > Save.
06:34Let's go over to our operating system, and let's open up index.html in our browser.
06:38Once it opens, we will hit Command+R or Ctrl+R to Reload, click on an image.
06:45The image fades up, caption fades in, I click on the image.
06:49This initiates the lightbox. I see the full screen image. I also see the caption
06:53down here, Caption for refraction goes here.
06:55Now in the lightbox, I can actually click anywhere;
06:57I don't have to hit just on the X. It zooms back into place. Click on another
07:03photo, come down and click on the View Larger Text.
07:08Now, notice that the image, if we use the Elastic setting, will create the elastic
07:12zoom based on the actual link.
07:14So the text link down here, the image will be really tiny, autoscale down to
07:19the size of the text link, and then zoom up.
07:21So now that this functionality is working perfectly,
07:24in the next movie, we're going to add another custom function for the update
07:27thumbnails, and then we're going to be able to set up a function that's going to
07:30autostart the gallery.
07:32So when we first load it, it will automatically highlight the first picture, set
07:35the thumbnail, and set the caption.
Collapse this transcript
Setting links to activate the lightbox feature
00:01Now, when we are inside of our gallery, when we hit Reload in the browser, one
00:05thing you'll notice is that we don't have a default image to show up here.
00:08The preview is only getting populated and faded in once we click on an image.
00:13Also, whatever image would show up also needs to have its thumbnail replaced.
00:18Now, the way we've written our script so far, the update thumbnails is actually
00:23part of the clickevent for all the anchor tags.
00:26So if I switch over to our JavaScript statement, we're going to scroll up here.
00:31We actually set this with these statements here, but again, they're inside the clickevent.
00:36In order to run these by themselves, we're going to put the thumbnail updater in
00:41its own function as well.
00:42So I'm going to come up here and I'm going to put two forward slashes in front
00:46of all of these statements.
00:47We're going to comment those out.
00:51Down here, lower in the page, we're going to create another custom function.
00:54I'm going to type function updateThumbnails, beginning and ending parentheses,
01:05beginning and ending bracket. Then we're going to just split this open.
01:12Inside updateThumbnails, what we're going to do is we're going to actually test
01:16the state of the thumbnails.
01:17Since we're no longer in the click event, we lose the actual event that we were
01:21using before to assign the classes.
01:23So, what we're going to have to do is cycle through all the anchor tags first
01:26and then check to see which anchor tags match the preview image that's showing up.
01:31So to begin this, let's start with a Dollar sign, beginning and ending
01:34parentheses, string literal, gallery_thumbnails, space, a. I'm going to come
01:47outside of that, .each, beginning and ending parentheses, semicolon.
01:55Inside of each, we're going to type function, beginning and ending parentheses,
02:01beginning and ending bracket.
02:03Now when we run the update function, the jQuery statement is going to run
02:07through every one of the anchor tags. And what we want to do is test the
02:10equality of the preview area to the actual anchor tag that's being tested.
02:17So we're going to type if, beginning and ending parentheses, beginning and
02:23ending bracket, and then we're going to split it.
02:27Inside of the if statement, we're going to type a Dollar sign, string literal, .gallery_preview
02:36space a, .attr. beginning and ending parentheses, href. Two Equal signs, we're going to test the absolute equality of this statement
02:52and Dollar sign, this.attr, string literal inside of there, href.
03:09So as we go through every one of the anchor tags, it's going to check the
03:12current one, which is the 'this' item and see if it matches what we wrote over
03:17into the gallery preview area.
03:19If they match, we're going to set jQuery statement;
03:24this, .addClass, string literal, 'selected'.
03:38On the next line, we want to fade out the child, the image tag that's inside of there.
03:45this, children, beginning and ending parentheses.
03:53Actually, we're going to use fadeTo.
03:57We want to actually animate this down. Beginning and ending parentheses,
04:02semicolon. And then inside here we're going to say 250, so a quarter of a second,
04:08and then .4. That's going to be the transparency.
04:11Let me scroll down here a little bit.
04:15Then we're going to type else, beginning and ending bracket.
04:19Let's open that up. Dollar sign, beginning and ending paretheses, this, .removeClass beginning and ending paretheses,
04:32string literal, selected, semicolon. Next line, this, .children, beginning and ending parentheses, .css
04:53beginning and ending parentheses, semicolon.
04:57Inside here, one string literal, opacity, comma, another string literal, number 1.
05:10So this puts this in a completely separate function.
05:13Let's grab updateThumbnails.
05:14Let's copy that to the clipboard.
05:17Let's scroll up, and right after setFancyboxLinks, let's paste that
05:20function there as well.
05:21So basically, we have removed this functionality from being inside the click-
05:26event, and we moved it into its own function.
05:30Now that we have the updateThumbnails out as separate function, this is going to
05:34allow us, in the next movie, to set up a statement that's going to autostart the
05:37gallery when the browser loads this.
Collapse this transcript
7. Taking Care of the Final Details
Initializing the gallery on page load
00:00Now to have our gallery autostart when we hit Reload in our browser, we're
00:03going to want a series of instructions very much like the onclick event
00:07functions we assigned to the anchor tag.
00:10So let's switch over to our JavaScript file.
00:13I am going to clean this up just a little bit, get rid of some of the negative
00:16space in here. And what we're going to do is basically grab the same instructions,
00:22starting from the declaration of these three variables all the way down to this
00:29ending statement here, which actually ends the fadeOut function for preview.
00:33I am going to hit Copy, copy this to the clipboard.
00:38Now, I need to stay within the document ready but outside of the anchor tag clickevent.
00:44That goes from here to here.
00:45So let's come outside of that area. Still inside the document ready.
00:51Let's put a comment for ourselves.
00:54We'll just say initialize gallery on load, hit Return, Command+V or Ctrl+V for
01:06paste, and we're going to paste in all of these instructions.
01:09So at the very top, we have these declarations.
01:13I am actually going to remove these tabs in here, get this formatted so now I
01:26can see this ending bracket here ends this statement here.
01:32So to begin, let's come up here, and the first four variables, let's just change
01:36these to have first_ in front of them.
01:39So let's copy, paste, paste, paste.
01:45We're also going to paste these in front of all of the variables within the script.
01:51So this becomes first photo preview, on line 43, this becomes
01:56first_photo_fullsize, first caption, first photo, first_photo_fullsize,
02:04first_photo_caption, first_photo_caption.
02:06Next, for the variables up here, since we're not inside that clickevent we
02:09don't know which object was actually clicked.
02:12So we're going to change the 'this' in here.
02:14Let's delete that, put in two quotes for a string literal.
02:18We're going type '.gallery_thumbnails a'. Outside of the parentheses, we're going
02:30to type.first(), and then the dot attribute, then the title string literal.
02:37This is jQuery's way of going through all of the anchor links and finding the
02:41first one in all of the anchor tags inside of the gallery_thumbnails div.
02:47Let's select this entire statement, copy it, come down to fullsize and hit
02:52Paste, change title string literal to href.
02:59Then just like in the other function, we're actually going to take photo preview
03:03and concatenate that by taking photo_ fullsize, doing a string replacement on the
03:08full-size text, and putting in preview.
03:11Everything else in here is going to run pretty much the same.
03:14Let's hit File Save.
03:15Let's come over to our browser. Hit Reload.
03:18What we'll see right away is the very first image fades up once it preloads.
03:25So I'll just click a few other images here.
03:26Let's come back, hit Reload.
03:30So now our initial state is working great.
03:33Now that our gallery is initializing on load, let's go add an email link and
03:37let's add some style to our View larger link.
Collapse this transcript
8. Styling the Hyperlinks
Adding icons and styles to the zoom and contact links
00:00Now we're going to add a hyperlink down for the contact section.
00:05Let's get our cursor down in here.
00:06We had put that default text in the beginning inside of the div.gallery_contact.
00:11Let's come in here and type 'Contact Me'. Let's select that.
00:19Down in the Properties panel, under the Link field, we're going to make this a
00:22hyperlink that will initiate a mail to: address.
00:24So we're going to type mailto, colon.
00:27Then you can put in your email, address info@lynda.com, hit Return.
00:36That will create a hyperlink.
00:37Over on the right-hand side, we had that default text in for where the caption goes.
00:41Let's just delete that text.
00:43So with a hyperlink created on the left, let's come over to our CSS Styles.
00:47Let's go to new hyperlink style, Compound path.
00:52We're going to say a.contactlink.
00:58This is going to be a brand-new class.
01:00We'll assign it into the anchor tag in a moment. Let's choose OK.
01:05The Properties, we're going to pick in here.
01:07Color, we're going to set to white. Text-Transform, all uppercase.
01:12No Text-decoration.
01:16Under the Box model, let's come under Padding.
01:19Let's turn off Same for all.
01:20We're going to set 0 on the Top, 30 pixels on the Right.
01:25This is going to keep the type inside the anchor tag 30 pixels from the
01:27right-hand side where we're actually going to position that envelope. 0 on the
01:32Bottom, 0 on the left, 0 for Margin.
01:37Lastly, let's come into Background.
01:40For Background image, we're going to choose Browse.
01:43Let's go into our template directory inside of images directory.
01:45We're going to grab the link_email. Click Choose.
01:50Background-repeat: we're going to say no-repeat.
01:54On the X, we're going to align it to the right, and we're going to set 0 on the Y axis.
02:00Click OK. Now in order to assign this here, I'm going to get a few characters inside of the link here.
02:06I'm going to come down to the document structure, click on the anchor tag to
02:09select the whole thing.
02:10I'm going to come down to the Class declaration inside of the Properties panel
02:15and select contactlink.
02:16Now what's interesting here is Dreamweaver doesn't actually preview this
02:20properly, but if we come up here and hit Live view and scroll down, we'll see the
02:26envelope showing up on the right-hand side here.
02:29Let's come out of the Live view.
02:30Now, we're on the right-hand side where the caption is.
02:34We actually have those inside of a p tag.
02:36So let's come over here to New CSS Rule, and create a regular tag.
02:41Let's come down to select the p tag. Click OK.
02:50Font color, let's pick a medium gray.
02:55Box property, Margins, 0 on the Top, 0 on the Right, 12 on the Bottom, 0 on
03:02the left. Click OK.
03:04Let's create one more rule, a compound rule.
03:09This is going to be the zoom link.
03:11Let's type a.zoom. Click OK.
03:18Color is going to be white.
03:19Text-decoration is none.
03:23Box properties, Padding, 0 on the Top, 0 on the Right.
03:29We're going to put 5 on the Bottom because height of the zoom actually needs
03:33a little bit more room below for the handle of that graphic. 20 on the Left.
03:39Set 0s on the Margin.
03:40Next, let's go to Background.
03:43We'll click Browse.
03:45We'll choose link_zoom. Click Choose.
03:49Under Repeat, we're going to say no-repeat, 0 on the X, 0 on the Y. Click OK.
03:55Now, the zoom link needs to be applied to the link that we're dynamically
03:59generating inside of this right-hand area.
04:02So let's switch over to our JavaScript document.
04:06What we're going to do is we're going to add a class into the overlaylink on
04:12the text one called zoom, and we're adding this in first on the clickevent for the anchor tag.
04:21So let me select this and hit Copy.
04:23We're also going to add it to the link down here, the overalylink, the
04:28text-based one that is inside the initialization area as well.
04:32Let's click Save on the gallery.
04:33Let's go back to Dreamweaver.
04:37Let's choose Save All, Option+F12, load in a browser, hit Reload.
04:44Now, I can see my styles down here. CONTACT ME highlights links to info@lynda.com.
04:51If I click this, it'll load this up in an email client.
04:54View larger has a little magnifying glass.
04:57We have our gray type down here.
04:58So as I click, we can see the type opening and closing.
05:02Well, this concludes all of the functionality for the interactive gallery.
05:05In the next movie, we'll talk about a few things you might want to consider for
05:08extending the capabilities of this particular project.
Collapse this transcript
9. What's New (April 2013)?
10. Where to go from here
Some ideas for further enhancements
00:00So now that you've completed programming your own photo gallery, there are some things you
00:04might want to consider to further increase the functionality.
00:08One of the things to take a look at is inside the Fancybox framework,
00:11there was that index file.
00:13We're going to open that up again.
00:15Down here under the set of examples, there's a group where we can take a series
00:19of images and load a series up in the lightbox.
00:22So by assigning a whole bunch of images to the same relative group, which
00:27we'll take a look at in the code for a moment, when we load up the lightbox,
00:30when we move to the right, we'll see that we have an arrow where I can click
00:33and go to the next picture.
00:36Now, when I roll side to side, I can go to the previous picture or the next
00:40picture, and I can cycle through any number of images.
00:44So basically, I can go from high-res file to high-res file.
00:47The way that this is set up,
00:49I am going to take a look at the index file in a text editor.
00:52I'm going to scroll down here and we're going to take a look at where this is
00:58set up. Down here in Image Gallery, they have a relative attribute here with an example_group.
01:04Every one of these items is part of the example_group.
01:07By simply grabbing another object, I'll take the last one and just paste it in
01:12again, so we'll have two copies of 12_b, which is a picture of that camera.
01:16I'll hit Save, come back to the browser, hit Reload.
01:20Notice I have now two pictures of the camera.
01:21No matter which image I click on, that's the one that starts.
01:25So I can go Previous, Next.
01:28We can also use the scroll wheel.
01:29So I am rotating the scroll wheel on my mouse.
01:32There are the two different pictures of the camera.
01:36Where we might want to use this in this particular gallery is perhaps we don't
01:41use the preview area at all, and we use just the series of thumbnails, and every
01:45one of these thumbnails is part of a relative group.
01:47So then bypassing the preview altogether, we click on a thumbnail and just bring
01:51up the lightbox where we can then go through all of the high-res images by
01:55either using the scroll-wheel or the right and left clicks.
01:59The next thing you might want to do is do a Google search on other photo
02:02galleries that you can download.
02:03A lot of people have put together plug-ins that will do a lot of the
02:06functionality that we've just gone through.
02:08So once you've spent the time to learn the techniques, you can either program
02:12your own and continue extending this project or start dissecting other projects.
02:16So typically, I'll go into Google and search for different types of slideshow
02:22galleries that I want to start from.
02:24So I can scroll down here and I can see a bunch of different plug-ins that I can
02:29download; some have some similar functionality. Or I can also use some of the
02:33user experiences of these to incorporate into my particular project.
02:38Well, at this point, I'm concluding this course, and I really appreciate
02:41you watching.
Collapse this transcript


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 98,466 instructional videos.

start free trial learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 1,893 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.


site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

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.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

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

   
submit Lightbox submit clicked