Watching:

Defining page structure for Sliding Panels


show more Defining page structure for Sliding Panels provides you with in-depth training on Developer. Taught by James Williamson as part of the Dreamweaver CS3 Projects: Creating Custom Spry Widgets show less
please wait ...

Defining page structure for Sliding Panels

At their heart, all Spry widgets are merely structured DIV tags controlled by JavaScript and cascading style sheets. Before we add the JavaScript and CSS to our page, we'll start by defining our widget structure. Some widgets can get fairly complicated so starting out with just the basic framework is a good way of making sure the widget will function as desired. So I've opened of the details_start.htm from the Chapter 4 directory. If you're following along with me with the exercise files, go in the Chapter 4 folder and you'll find details_start.

So a lot of what we'll be doing is hand coding. So I'm going to switch over to Code View, and I can collapse my panels so that I can see my code a little bit better, and I'm going to scroll down to line 45. Now on line 45, we can see that we have a DIV tag called panelContainer. This is going to hold our Spry widget and the reason that we are going to encase this in another DIV tag is so that we can give it a little additional styling. So I'm going to hit Return and go down to line 46; it's going to be all on its own line. And I'm just going to create a new DIV tag.

So we'll do DIV and the ID for this one is going to be detail, capital S, Slide, number one. We're also to be using classes extensively with this widget. We're going to assign a class attribute of Sliding Panels. And we'll close that and hit Return and close our DIV tag. Now, you might be wondering as we create this structure where I'm getting these ID names and class names from. I'm getting them from the external JavaScript file and external CSS file. So as you're structuring and building your own widgets, pay very close attention to what ID names and what class names are being either passed into the JavaScript function or assigned dynamically through the JavaScript function so that you'll know what to make them. And actually all the tutorials, all the sample files should be very clear as to how that structures going to be set up.

So now we have a DIV tag that's going to surround all or our Sliding Panels. I'll go ahead and we'll just create another DIV tag to hold the Sliding Panel's content group. So we'll do another DIV tag inside of our detailSlide1 and it's only going to have a class attribure and it's class attribute is going to be capital S, Sliding, capital P, Panels, capital C, Content, capital G, Group. So that's a long one. SlidingPanelsContentGroup. Most of the names make sense if you think about them. If you really pay attention to what you're naming everything, it should make a good bit of sense. So we're going to go ahead and close that DIV tag as well.

So right now our structure has an outer DIV tag called detailSlide1, and we have an inner DIV tag with a class attribute of SlidingPanelsContentGroup. After we're done with that, we need to insert a DIV tag for each panel of content and in our exercise, our widget will have four panels for the four products we're going to be highlighting. We need to create four of these. So I'm going to create a DIV tag inside my SlidingPanelsContentGroup and I'm giving it an ID of panel0. That ID is one that I came up with. That's not required for our Sliding Panels widget.

Dreamweaver is going to build an array of these panels in JavaScript so obviously most arrays start counting at zero so by calling the first one panel0, I'll understand which one it's talking about it if I ever having to cycle through by element ID and find out what it is. Now after that, I'm going to type in class and this one is going to be SlidingPanelsContent. Obviously, spelling and capitalization really matter here , so capital S, capital P, capital C and notice that panel's plural, content. Now I'll go ahead and put some placeholder content inside of this so I'm just going to type in 'First Panel Content' before I close the DIV tag.

The same structure holds for all these so I'm just going to copy this code and paste it. The next thing I have to do is change the ID from panel0 to panel1. The class remains the same. So that's one reason why we're using a class here; we can apply the class over and over and over again, no matter how many panels we have. I'll change the placeholder text to Second Panel Content. Just go ahead and do that a couple more times, changing it to panel2 and then Third Panel Content, and then finally changing it to panel3 and then Fourth Panel Content.

Now the one thing that might trip you up here a little bit is the fact that we're starting our IDs at zero, but then we're saying first, second, third and fourth panel content. So keep in mind that panel3 will actually hold the fourth panel content. Alright I'm going to go and save the file and I'll switch back over to Design View. I can clearly see the structure, so just below my thumbnails, I have a DIV tag that holds the first panel, second, third and fourth panel content. We now have our clean, structured markup necessary to create our Sliding Panels. Before adding the necessary scripting, we'll go ahead and replace our placeholder content with the actual content of the panels.

This process is simplified considerably by having the structure already in place.

Defining page structure for Sliding Panels
Video duration: 4m 53s 1h 0m Intermediate

Viewers:

Defining page structure for Sliding Panels provides you with in-depth training on Developer. Taught by James Williamson as part of the Dreamweaver CS3 Projects: Creating Custom Spry Widgets

Subjects:
Developer Web
Software:
Dreamweaver
Author:
please wait ...