navigate site menu

Become a member and get unlimited access to every course in the library. Try it free for 7 days

Dreamweaver CS4: Introduction to Spry

Dreamweaver CS4: Introduction to Spry

with James Williamson

 


Web designers with no prior JavaScript experience can now easily add AJAX-driven functionality to their sites. Adobe Certified Master Instructor James Williamson demonstrates how in Dreamweaver CS4: Introduction to Spry. This course covers the three main focuses of Spry: creating interactive effects, using widgets to shape the user experience, and populating pages with data. Exercise files accompany the course. A working knowledge of HTML and CSS is recommended for this course.
Topics include:
  • Validating form data to give users robust feedback
  • Customizing widgets to meet the style of a web site
  • Building a pull-down menu navigation system
  • Serving alternate content to users who do not have JavaScript enabled
  • Pulling data from XML, HTML, and Excel spreadsheets
  • Constructing datasets and widgets using code

show more

author
James Williamson
subject
Developer, Web, Web Development
software
Dreamweaver CS4
level
Intermediate
duration
4h 12m
released
Apr 29, 2009

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
Welcome
00:00(Music playing.)
00:06If you're a web designer who wants to add AJAX-driven functionality to your sites,
00:10but you've been held back due to lack of experience with JavaScript,
00:13then this title is for you.
00:15Welcome to Dreamweaver CS4 Introduction to Spry. I'm James Williamson,
00:19Adobe Certified Master Instructor and Director of Training for Lodestone Digital.
00:24In this title, we'll examine the three main focuses of Spry, creating amazing
00:29interactive Spry effects, using pre- built Spry widgets to create immersive user
00:33interface experiences and how to populate pages using Spry's robust data capabilities.
00:39Along the way, we'll cover how to validate form data using Spry, allowing you
00:43to give your users detailed feedback as they fill out your forms. We'll also
00:48build pulldown menus using Spry and learn how to serve alternate content to
00:52users who do not have JavaScript enabled.
00:55As we work with Spry data, we'll explore the many different ways that Spry can
00:58collect and display data using it to pull in data from XML, HTML and even Excel
01:04spreadsheets on the fly.
01:06All this as they say and much more. Although you don't need to know JavaScript
01:11to complete this title, a comfortable working knowledge of HMTL and CSS is
01:15recommended. There are many fantastic titles on the lynda.com Online Training
01:20Library on HTML and CSS. If you are new to web design, I recommend you start
01:25there before learning Spry. Okay, let's get started. [00:01:29.8]
Collapse this transcript
Setting up Spry management
00:00Before we get started with learning more about Spry, I want to take just a
00:04moment to talk about something that's going to be very, very important for this
00:07title and that's managing your Spry assets.
00:09Throughout the title, we'll need to redefine Spry's default Spry assets
00:13directory, so that when we create Spry elements on our page, our assets are
00:17copied into the right folder.
00:19Now in each exercise that we do this, I'll give you brief instructions on how
00:23that's done, but I think it's worth going over before we get into the title so
00:27that you're aware of why we're doing what we're doing. So to control the
00:30default Spry assets directory in Dreamweaver, you just go to your Site
00:33Definition dialog box. The easiest way to get to that is go over to Files
00:37panel, find the name of your site in this pulldown menu and simply double-click.
00:42When you do that, the Site Definition dialog box will come up, just click on
00:46the Advanced tab, you want to go down to the Spry category. In the Spry
00:50category, there is only one option and that's, hey, where should the default
00:54Spry assets directory be?
00:56Now, by default, Dreamweaver will copy your Spry assets over to a directory on
01:00the root folder called Spry assets. If that folder does not exist, Dreamweaver
01:05is going to create it for you. Well, using this method you can take control of
01:09exactly where does it place. So if you click the Browse folder, you can go
01:13anywhere throughout your site and tell exactly where to place your Spry assets.
01:20So as we get into specific exercises, I'll give you instructions on exactly
01:23which folder and directory should be the current default Spry assets directory.
01:28Make sure that you use this method to set it before completing the exercise,
01:32that way our Spry assets won't be overwritten, modified, or ignored and
01:37everything should work properly.
01:38I'd also like to point out that I use a custom workspace in this title. Now if
01:42you're curious about my custom workspace, I'll go ahead and show it to you now,
01:46that way, if you want to build the same exact workspace that I use,
01:49you're free to do that.
01:50Now I'm just going to open up the page here and you can open up any page or you
01:53can do what I'm going to do which is just to create a blank page. I just want
01:56to make sure I'm looking at the default workspace. So as I modify it, I know
02:00exactly what I'm doing here.
02:02Now I really like the Split-Screen View but I don't like that to be my default
02:05view, so the first thing I'm going to do is just switch that to Design View so
02:09that that's my default view.
02:10The next thing I'm going to do is I'm going to take the Insert toolbar, which
02:13is by default over here on the side, and I'm going to move that over here above
02:18the document window. Now I can do that manually or I can just switch workspaces
02:21because the Classic workspace has that, you've got to remember, go back to
02:25Design View. So by switching to Classic the Insert toolbar is exactly where I want it.
02:29Now I'm going to change one more thing. When I'm working in Dreamweaver,
02:33I really like to have access to my page validation and checking for browser
02:37compatibility in running reports and doing searches and Find and Replaces right
02:41at my fingertips. I really like to have that functionality.
02:44Well, that's in a whole set of panels, we can get by going to Results and
02:47choosing any of these options. I'm just going to go ahead and choose Search.
02:50Now, you'll notice that it went ahead and docked this just below the Properties
02:54Inspector. It's not exactly the most efficient layout, so what I'm going to do
02:58is I'm going to take the tab of the Properties Inspector, I'm going to drag
03:02that over this panel grouping and now my Properties Inspector is part of this
03:06much larger group.
03:08Now, most people like the Properties Inspector to be over here on the left-hand
03:11side, so I'm going to grab that and just simply slide it on over until it is
03:16the leftmost panel.
03:17Now, in addition to my Properties Inspector, I have the Search, Reference,
03:22Validation, Browser Compatibility, all of these groups of panels down here. So
03:27that just makes my life a little bit easier.
03:29Now once I've got that workspace set, I'm going to save it, so I'm going to go
03:32up to my Workspace Switcher right up here at the top and I'll choose New
03:36Workspace and I'm just going to call that one The James, feel free to insert
03:40your own name.
03:41Now no matter what happens, no matter how things get changed up or moved around
03:46or undocked or resized, I can go right back to The James and I get exactly what
03:52I'm looking for, perfect!
03:53So keep in mind that as we go into each new exercise, we may need to redefine
03:58the Spry assets directory, and now we know how to do that, and also, if you
04:02want your workspace to match mine, you can just build this workspace for yourself.
Collapse this transcript
Using the exercise files
00:00If you are a premium member of the lynda.com Online Training Library or
00:05if you are watching this tutorial on a disc, you have access to the Exercise Files
00:09used throughout this title.
00:11To use the Exercise Files, I recommend that you copy them or download them to
00:14your desktop. From there in Dreamweaver, you're going to define the site using
00:19the Exercise Files as your root directory. So I'm going to go to Site, choose
00:24New Site. Now you can name this anything that you want. I'm going to go in the
00:27Advanced Site Definition dialog box and I'm just going to name this spry_intro.
00:34I'll browse out to my Desktop, find my exercise_files folder and I'll select
00:39that. Now on the PC, you'll choose Select and on the Mac, you'll choose Choose.
00:44As soon as I click OK, it will cache the site up for me.
00:49Once your site is defined, in the Files panel you'll have access to all the
00:53Exercise Files organized by chapters. So as you're following along with me with
00:57the Exercise Files, you'll simply go into the appropriate chapter, open the
01:01Chapter folder and open the Exercise Files within.
01:05If you are a monthly or annual subscriber to Lynda.com, you don't have access
01:09to the Exercise Files but you can follow along from scratch or from your own
01:13assets. Let's get started.
Collapse this transcript
1. Introducing Spry
What is AJAX?
00:00Although the term AJAX has been around since 2005, there is still some
00:04confusion about just what AJAX is. One of the most prevalent misconceptions is
00:09that AJAX is a new standalone technology for creating interactive web pages.
00:13In reality, AJAX, which stands for Asynchronous JavaScript and XML, is a
00:18combination of several existing standards and technologies, all working
00:22together to create a more seamless and engaging user interface.
00:25In the narrow sense, AJAX refers to the process of eliminating the need to
00:30refresh every time data on a page is either changed or added. In a much broader
00:35sense, the term AJAX is now used to describe almost all user interactions
00:38improved through the combination of CSS, XHTML and JavaScript.
00:44Take one of the first and still one of the most popular AJAX-driven
00:47applications, Google Maps. Before the use of AJAX, users would have had to
00:52request a specific map, wait for the database to be queried and then be served
00:57a brand-new page with their new map displayed on it.
01:00For each map requested, the server would have had to process that request and
01:03then serve up a brand-new page. This process is not only inefficient for most
01:07applications, it doesn't give the immediate feedback that users want in an interface.
01:12Through the use of AJAX, users can get updated map information as it's
01:16requested, even updating the maps as users scroll from one area to the next. So,
01:21what technologies make up AJAX?
01:23Well, you should keep in mind that AJAX is kind of a loose term. It means
01:26different things for different people. However, the most widely accepted
01:30definition of AJAX components includes a well-structured XHTML, CSS to control
01:36the presentation and JavaScript to control user interaction, data requests and
01:41DOM manipulation.
01:42XML and XSLT are typically used to store and write data but they aren't
01:46required and, in fact, any server-side technology can be integrated into the
01:50process to handle business logic and data.
01:52Now, in addition, some AJAX-driven applications make use of I-frames and DHTML
01:57while other AJAX developers avoid using them altogether.
02:01The biggest factor in the rise of AJAX- driven applications has been the release
02:05of structured JavaScript frameworks. That makes it much easier for web
02:08designers and developers to create AJAX-flavored sites.
02:12Some of the more popular frameworks include JQuery, Prototype and MooTools.
02:17It should be noted that almost none of them refer to the term AJAX in their
02:21documentation. That term is more of a catchall phrase to describe asynchronous
02:25interfaces rather than to describe the actual process or the frameworks themselves.
02:30Adobe's JavaScript framework is called Spry and it is an INET framework, aimed
02:35that designers and developers, who are looking to enhance the user experience
02:39without having to write a lot of additional code.
02:42Adobe has integrated Spry into Dreamweaver making it easier than ever to create
02:45AJAX-driven websites. In this title, I'll introduce Spry and show how you can
02:50use it to create richer user experiences within your websites.
02:54Although Adobe automates much of the process of integrating Spry into your web
02:57applications, it's a good idea to have a solid understanding of the
03:00technologies and standards that Spry relies on, so that you can go beyond its
03:04default appearances and functionality.
Collapse this transcript
What is JavaScript?
00:00One of the most important components of any Spry enabled page is the underlying
00:04JavaScript that controls its functionality.
00:06JavaScript is a scripting language that was developed in 1995 by Netscape and
00:10has been gaining in popularity ever since. Although it shares a similar name,
00:14JavaScript actually has nothing to do with the programming language Java, and
00:18it's important not to confuse the two.
00:20Netscape simply licensed the term Java from Sun to help in the adoption of
00:24their new scripting language. I guess it worked, since JavaScript is still
00:27around and Netscape, well, for the most part isn't.
00:30JavaScript allows you to do things within the browser that XHTML can't do;
00:35by creating interactive rollovers, controlling browser window properties,
00:39validating forms, and generating dynamic content.
00:42As it relates to web development, JavaScript runs in the browser and not the server,
00:46which makes it a popular choice for client-side scripting.
00:50One of the downsides to this however is that each browser has its own
00:53JavaScript interpreter which can make for some frustrating cross browser issues.
00:58Like most popular web development languages, JavaScript is an object-oriented
01:02programming language. Object-oriented programming languages are by definition
01:06made up of objects and classes of objects that make scripting applications with
01:10them much easier.
01:11For example, let's say we want to have our page send an email to us when a user
01:16fills out a form. Almost all server- side languages have a mail object that make
01:21sending and formatting emails much easier. We simply create a new instance of
01:25the mail object and then use its pre- built methods and properties to format and
01:29send an email.
01:30One of the main differences between JavaScript and most web development
01:33object-oriented programming languages is that in JavaScript, objects are
01:37created by attaching methods and properties to otherwise empty objects at
01:41runtime. This is very different than the majority of compiled languages like
01:45C++ and Java, which use predefined class definitions to store common objects in
01:50their properties.
01:51This difference is one of the driving factors behind the rising popularity of
01:55pre-built JavaScript frameworks and libraries. Instead of having to build
01:59objects to control animation, interactivity, and data handling, the developer
02:03can simply use the predefined objects inside the chosen framework.
02:07This also makes it very easy for web designers that are not fluent in
02:10JavaScript to add advanced functionality to their pages. Indeed, Spry was built
02:15with designers in mind, making the JavaScript unobtrusive and easy to
02:19communicate with.
02:20Although by using Dreamweaver and the pre-built Spry JavaScript libraries,
02:23you don't really have to know JavaScript to add Spry functionality to your pages,
02:27I can't recommend highly enough that you learn JavaScript. With a functional
02:32knowledge of JavaScript, you'll be able to extend the existing Spry framework
02:35and tweak the existing libraries to do exactly what you need.
Collapse this transcript
What is XML?
00:00Another important component of many Spry driven sites is the use of XML to
00:04store and display data. XML is a common markup language used to share
00:09information across multiple platforms, and is widely used across all types of
00:13web applications.
00:15As a markup language, XML is very similar to HTML. It stands for Extensible
00:20Markup Language and is the W3C's recommended specification for general-purpose
00:25markup. This means, unlike other markup languages, XML is not predefined and is
00:30made up of the tags that you create to describe the structure.
00:33The primary purpose of XML is to share data across different systems, since any
00:38system that understands the current document structure can access and use its data.
00:42Although the tags in XML are not predefined, XML documents must conform
00:47to specific syntax to be considered valid. Well-defined XML document must have
00:51a root element. The elements must have both opening and closing tags.
00:55Invalidly nested tags are not allowed. Attributes must be in quotation marks
01:00and XML documents generally have a declaration that identifies aspects of the XML file.
01:05The complete XML specifications can be found online at the W3C's
01:10XML Recommendation page.
01:12The typical structure of a simple XML file is to have a root element that
01:16describes the contents of the page and then repeating child objects that
01:20contain data in attributes of specific objects.
01:24Here for example, I have the contributors.xml file open. You'll notice that we
01:28have a root tag, the contributors tag, and if we go all the way down to the
01:31bottom, we'll see the contributors tag close. Inside of that, we have repeating
01:35child elements, and in this case we have one repeating child element:
01:39the photographer. In each photographer, we have an attribute value that's giving
01:43the name of the photographer, and then thus followed by the country, city, and camera.
01:50So that repeating structure makes it very easy to store data, and any
01:53application that understands this structure could find the name of our
01:56photographers, the country of origin, the city that they live in, and the
02:01camera that they use.
02:02As for Spry, Spry can use any valid well-formed XML file to built datasets for
02:07displaying content on your pages. The XML can be freestanding or it can be
02:11generated using server-side technology based on databases or any other data
02:16source. This creates a very flexible and powerful means for storing,
02:20manipulating, and displaying data within Spry.
02:23We will discuss creating XML datasets in Spry in greater detail later.
02:27For the moment, I would recommend becoming familiar with the structure and syntax rules
02:31surrounding XML documents, so that you can ensure you are using well-formed and
02:36valid XML within your applications.
Collapse this transcript
Spry overview
00:00Spry is Adobe's JavaScript based framework that allows you to create powerful
00:04Ajax driven web applications. Unlike other JavaScript frameworks, Adobe's goal
00:09in building Spry was to have the framework seem like an extension of HTML and
00:12CSS. That way anyone with basic web production skills should be able to create
00:17Spry enabled pages.
00:19To make Spry even easier to implement, Adobe has integrated it into Dreamweaver
00:22since version CS3. As a designer, you can add advance Spry functionality
00:27directly from the Dreamweaver interface.
00:29Spry is essentially made up of a set of JavaScript and CSS libraries. To use
00:34Spry on a page, you include the JavaScript file that contains the Spry features
00:38you need. Reference those features on the page. Link to the CSS that controls
00:42the presentation of the Spry elements, and then deploy the JavaScript and CSS
00:47files to your site along with your page. For those Spry features that are
00:50integrated into Dreamweaver, that entire process is automated for you.
00:55Spry is made up of three core components. These are Spry data, which handles data.
01:00Spry widgets, which can be thought of as pre-built interactive
01:03components. Spry effects, which can animate, hide, or otherwise modify page
01:09elements. These can be used independently or combined together to create
01:13compelling user experiences.
01:14Well, here in my browser I have one of those Spry widgets that I was talking
01:18about opened up. This is an Accordion widget and you'll notice it allows me to
01:22present a lot of information in a very small space.
01:25Here we have the three bios of the founder sof the site, and they're presented
01:28in a very interactive, engaging manner through the use of Spry.
01:33Exactly how much work did it take to get that? Well, let's go back into
01:36Dreamweaver and check it out.
01:37So here we are back in Dreamweaver, and if I switch over to Code View, we can
01:41see that we've got two lines of code at the very top of the page, and these are
01:45linking to external Spry Assets.
01:48If I scroll a little bit further down the page, I see that I have a collection
01:53of div tags that are surrounding all of my bio information. So this is just
01:56normal XHTML structure. Each one of these is identified with classes and IDs
02:02that help create the widget structure.
02:03Then at the very bottom of the code, there is one line of JavaScript that
02:08creates and enables our new Accordion widget. So you can see, it doesn't really
02:13take a whole lot of effort or work to achieve some really nice functionality with Spry.
02:18Another thing that I'd like to mention is that Spry can also be used with any
02:21server-side technology. That means that you could build the user interface of
02:25your application with Spry, thereby creating a richer user experience that is
02:29separated from the back-end application logic.
02:32While Dreamweaver CS4 has integrated Spry features, they are by no means
02:35complete, and Spry itself is completely tool-agnostic. You can create and
02:40deploy Spry from any code editor that you choose to use, or hand-code Spry
02:44through Dreamweaver. In fact, there are so many Spry features that are not
02:48integrated into Dreamweaver, I highly recommend digging deeper into Spry and
02:53learning how to control it manually.
Collapse this transcript
Downloading the Spry framework
00:00Although Dreamweaver ships with much of the Spry framework, Adobe is constantly
00:04updating and adding to it. In fact, Spry is still considered to be in beta.
00:09Before starting any Spry project, you should check to make sure you have the
00:12most current release. As of this recording, the Spry 1.61 release is the most
00:18current version. Although Dreamweaver CS4 shipped with Version 1.6, Adobe has
00:23created a Spry Updater for Dreamweaver, which can update any previously built
00:27Spry content to the latest version.
00:30You can download both the Spry 1.1 release as well as the Dreamweaver Updater
00:34from Adobe's Spry homepage, and here we are at Adobe's Spry homepage.
00:39You'll notice on the left-hand side we have a lot of information about
00:42Documentation and Samples, and we'll talk more about that a little bit later
00:45on. Right now, I want to talk about downloading the Spry framework; that's a
00:49must for anybody that's going to be working with Spry, even if you have the
00:52latest version of Dreamweaver.
00:54On the far left-hand side, this is the Dreamweaver Spry Updater. So if you've
00:58built some applications with an earlier version of Spry, something prior to
01:011.6, you'd want to download that using the Extensions Manager and then update
01:06your older pages.
01:07However, if you're looking for the Spry framework, you can find that right up
01:10here in the upper-left hand corner. I should point out that if you download the
01:14entire Spry framework, the Dreamweaver Spry Updater is included. So I'm going
01:18to go ahead and click to Download the Spry framework. Before you download it,
01:23you'll need to enter in an Adobe ID and your Password. And if you don't have
01:32one of these, they're free. So just take a moment or two to sign up, and you'll
01:37be downloading Spry in no time.
01:38This will take you to the Download page, where you have to agree to Terms of
01:42Use. It will discuss what the latest version is, and the download for both Mac
01:47and Windows is the same file, and it's a zipped file, and all you have to do to
01:51install the Spry framework is extract it.
01:59So here I've got the Spry framework that I've downloaded. I'm going to go ahead
02:02and extract that, and it's going to take a second or two. But as soon as it's
02:08finished extracting, we're going to take a look inside and see what is included
02:11with the release of the Spry framework. Okay, there we go.
02:18Inside the Spry folder you're going to find a wealth of information. In
02:22addition to all the files that you need; and you can find those in the Includes
02:26folder, here we have a whole set of JavaScript library that contains utilities
02:31and datasets. We also have widgets, such as the SlidingPanels widget, that
02:37we'll be building later on. So here is all the files necessary to build that.
02:40There are different versions that they've got as well. They do have the
02:44minified versions, so for deployment you may want to use those, to save a
02:47little bit of space and save on bandwidth.
02:50But I do want to point out that the Dreamweaver Updater is included as part of
02:54this install, plus we have articles, demos, samples, a couple of HTML files
03:00that you can open up and pick through and see exactly how they're building
03:02stuff. So it's not just the JavaScript files that are included with the Spry
03:06framework, there is a lot of information there to get you started and to help
03:09serve as a point of reference for you, as you continue to go deeper into Spry.
03:13Well, now that the Spry framework is installed and ready to use, let's take a
03:17look at Adobe's online Spry documentation, which should serve as a starting
03:22point for any project using Spry.
Collapse this transcript
Using Adobe's online Spry documentation
00:00To get the most out of any Spry based project, you should take advantage of
00:03Adobe's extensive series of tutorials, samples, and documentation on the Spry
00:08homepage. Whether you are using them as a starting point or as a reference,
00:12these files offer a wealth of information about working with Spry.
00:15So here we are on the Spry home age, its labs.adobe.com. You can see on the
00:21left-hand side here we have links to Demos, Documentation, Samples, Forums,
00:26Adobe's Development Center, with a focus on Spry, so there's a lot of really
00:30good information here.
00:31Now, let's take a look at the Documentation first. So the Spry Documentation
00:35looks pretty plain, but there's some really cool stuff in here. So as I scroll
00:40down, you can see we have some overview articles about data sets and regions, a
00:44primer on Spry, and if you're new to technologies like XML and JavaScript,
00:48there's also some links on here for you as well.
00:50If you want to work with Spry data, we have a whole series of articles on
00:54working with data.
00:56Each widget has its own page, and let's go check the Sliding Panels widget out,
01:01where it describes exactly how the panel works and gives you some code sample
01:06to show you how the widget is built and controlled.
01:08Well, in addition to the Documentation, we also have some Samples. On the
01:14Samples page, we have a whole series of samples that range from both basic to
01:18really advanced stuff. You can come check out examples on using Spry Data, the
01:23Utilities that come with Spry, things like Effects, widgets.
01:28So here is the Accordion Panel Sample, and they've got a whole series of
01:33samples. So let's just check out the Default Behavior and Style, and you can
01:37see it in action. You can also go in and check out the code and break it down
01:41and see how you'd use it in your own pages.
01:42Now remember, there's more here than just the Documentation and the Samples,
01:48there's also a set of Forums, a Blog that's updated on a continual basis to let
01:52you know what's new in Spry. You can go to the Development Central to find
01:55longer articles and tutorials.
01:58By spending some time on the Spry homepage and examining the Spry framework
02:02documentation carefully, you'll find an entire world of functionality and
02:05capabilities that, not only will enhance your understanding of what you'll find
02:08in Dreamweaver's normal toolset, but that will also go well beyond it. Any
02:13designer or developer that is considering adding Spry functionality to their
02:16pages should have these pages bookmarked and should visit them frequently.
Collapse this transcript
Dreamweaver-Spry integration
00:00To make deploying Spry even easier for web designers, Adobe has integrated
00:04large parts of the Spry framework into Dreamweaver. Dreamweaver allows you to
00:08automate the process of adding Spry functionality to your site, speeding up the
00:12development process and making it possible for designers who are not fluent in
00:16JavaScript or web development to create Ajax driven sites.
00:19In this movie, we'll take a brief tour of where to find Spry elements in
00:23Dreamweaver. Before we get into exactly where to find everything Spry related,
00:27I want to point out the Help features that Dreamweaver has, related directly to Spry.
00:32So if I go up to the Menu to Help, I can see that the first link is to the
00:36normal Dreamweaver Help. If I go to the online Help directory, I can see that I
00:42have an entire section on Building Spry pages visually, where we get overviews
00:47of working with the different widgets, working with the Spry framework, and
00:50where to find everything within Dreamweaver. That's really cool!
00:53Now, I don't know if you noticed it or not, but I'm going to jump back into
00:56Dreamweaver, and you may have noticed that directly under the Help file there's
01:00this cool little Spry Framework Help. Let's go ahead and click on that and see
01:04what that's all about.
01:05Now, this takes me to Adobe's LiveDocs page, to the Spry framework for Ajax
01:11Developer's Guide. Here we have sections on working with Spry widgets, working
01:15with data sets, building dynamic pages, and also working with Spry effects, so
01:20there's a lot of information here as well. So you might want to use either of
01:24these Help sections, if not both of them, as a starting point for working with
01:28Spry and Dreamweaver.
01:29Now, let's go back into Dreamweaver and see where in the interface we can
01:33access all these really cool Spry tools. So here we are back in Dreamweaver.
01:37One of the most obvious places to look for Spry functionality would be an
01:41Insert toolbar, and indeed, Spry has its own toolbar. You'll notice its broken
01:46up into sections, and the first section involves dealing with Spry Data. The
01:50second section involves the Spry Form Validation widgets, and then the third
01:55section involves the User Interface widgets.
01:57Now, that's not the only place we can find those, you'll notice that if I look
02:01in Layout, I have the User Interface widgets. If I look in Forms, I have the
02:06Form Validation widgets. If I look in Data, there are all the data elements
02:11involved as well. Now, those are exactly the same as the ones that we find in
02:14the Spry Insert toolbar, they're just placed there so that as you're working
02:18with those types of objects, you will have access to the Spry objects as well,
02:21which in my opinion is pretty darn nice of them.
02:23That is not the only place where you can find Spry functionality in
02:27Dreamweaver. If I go over to the Tag Inspector and I look at the Behaviors
02:32Panel, you may have noticed this before, because Behaviors has been around for
02:35a very long time inside Dreamweaver, but something that's rather recent to
02:39Dreamweaver is this little Effects fly-out Menu there.
02:41Well, those are all Spry Effects. So if you add one of these. Let's say you
02:45take something in Grow it or Shrink it or Fade it out, you're actually using
02:50Spry, even though you might not have known it.
02:52At some point in the process of using Spry, you are going to figure it out. Let
02:56me show you what I mean. Let's say I highlight the word home" here and I insert
03:00a Spry Tooltip widget. This is a really neat little feature that enables the
03:04Tooltip; if you hover over something, it will float the Tooltip up. Here's the
03:09Tooltip content right down there. Let's just type in Click here to go home. Not
03:15the best Tooltip I've ever done in the world, but it will suit our needs.
03:18So if I save this file, notice that Dreamweaver is telling me, hey, you need
03:23certain files in order for this functionality to work, and these are what we
03:26call Spry Assets. Its going to copy those over to my site, and when I click OK,
03:30if I were to Preview in this Live View and I were to hover over home, you'll
03:34notice that there is the Tooltip. Perfect!
03:37So you can see that Dreamweaver makes adding Spry functionality to our pages
03:42really, really easy. As a matter of fact, it's as easy as adding any other page element.
03:46Keep in mind that the process of adding Spry to your pages will require
03:50Dreamweaver to link to and add external assets to your site. Managing those
03:55assets and making sure that you don't disable functionality, by either removing
03:59or failing to update links is extremely important, and will be a continuing
04:03theme for this title.
04:04We'll also take a closer look next on how to plan strategies for managing those assets.
Collapse this transcript
Managing Spry assets
00:00One of the biggest challenges when working with Spry in Dreamweaver is managing
00:04the Spry assets that are necessary for your Spry elements to function. When you
00:08add a Spry element to your page and save the file, Dreamweaver is going to add
00:12the necessary external asset files to your site and link them to that page.
00:17By default Dreamweaver is going to add those files to a folder named SpryAssets
00:22that it will locate inside the root folder if that folder doesn't already
00:26exist. It will just go ahead and make it for you. For the most part this
00:30process is fairly painless and requires you to only upload the SpryAssets
00:34folder along with the rest of your site, when you deploy it.
00:36However, when things get a little bit more complicated, it's really easy for
00:40these assets to get mixed up, overwritten or removed without updating the link.
00:45By being aware of how Dreamweaver adds these files and what you can do to
00:48control them, you can avoid any serious problems.
00:52So here I have the contact.htm file open from the 01_08 folder and if I scroll
00:57down in the sidebar here, I can see where I like to put a tabbed panel widget
01:02where the users could tab back and forth between the featured photographs. So
01:05far so good, right? So I'm to go right up here and I'm going to click to Insert
01:09a Spry Tabbed Panels widget. When I do that, I didn't get kind of what I
01:14expected here. So let me save the file. Notice I didn't copy over any files
01:20even when I saved it. So, what in the world is going on here? This does not
01:23look like the default Tabbed Panels widget and I thought it was going to copy
01:27over some files since I was asking for a brand new widget.
01:30Let's try to figure out what's going on here. If I open up the shop.htm, I can
01:34see that this one already has a Tabbed Panel widget. And this particular Tabbed
01:38Panel widget is designed specifically for the shop page. So the styles and the
01:42functionality of it have been overwritten from the default. Okay, so, what
01:47happened with our other page is that when we ask for a Tabbed Panel widget
01:51here, Dreamweaver saw that in the SpryAssets folder those assets were already
01:55there. So instead of overwriting them, it just figured, oh, you must want to
01:59use those again.
02:00Well, that's not going to be true in every single case. And as a matter of
02:03fact, if you guys were doing this along with me, I really doubt that you saw
02:07the same result that I did. You probably saw a brand new default Tabbed Panel
02:11widget and you probably saw files getting copied over. So what in the world is
02:15going on here?
02:16Well, one of the really cool things about Spry and Dreamweaver is that in terms
02:20of the Spry assets, you can tell Dreamweaver exactly where it should place
02:24those files. Before the exercise, I kind of achieved it a little bit and I told
02:28it to place it in the 01_08 SpryAssets folder. How could I have avoided what
02:33just happened here? Let's go ahead and Undo this little Tabbed Panels. And I'm
02:38going to help to place these asset files separate from my other ones, in that
02:42way, I'll have two sets of the Tabbed Panel assets and I'll be able to control
02:46and modify them separately.
02:47So here's how we do that. I'm going to go over to the 01_08 folder. I'm going
02:51to right click and choose to create a New Folder. Just going to call these
02:56photoAssets since they are going to deal with my featured photos. If I go up to
03:01the Site Definition, here is the name of my site, right here, spry_intro. If I
03:04double click that, that opens up the Site Definition dialog box. Now this is
03:08something we are going to do a lot of in this course. I'm going to go all the
03:11way down to the bottom category, which is Spry, and right here is where I can
03:15browse and tell Dreamweaver where it should be placing the Spry assets from my site.
03:20So if you want to place them in a different directory or if you want to create
03:22several different sets, this is how you do that. So I'm going to go ahead and
03:26click on this folder to browse, I'm to go up into the 01_08 and choose the
03:31photoAssets folder. I'll select then I'll click OK.
03:34All right, let's try that again. I'm going to click in the Featured Photos and
03:39I'm going to insert a new Spry Tabbed Panels, there we go. Now I'm getting the
03:45default styling and if I save it, notice that it's copying over the
03:49SpryTabbedPanels.css and the JavaScript file. And notice where's it's copying
03:53them to. To the photoAssets directory.
03:56So using this method, I'm now in control of exactly where all of my Spry assets
04:01are added to my site. So I hope this exercise demonstrates how important it is
04:05to have a plan for managing your Spry assets. By planning ahead of time, which
04:10assets your site will need and how those assets will be modified and deployed,
04:14you can avoid having any unfortunate styling conflicts and non-functioning elements.
Collapse this transcript
2. Spry Effects and Spry Widgets
Understanding Spry effects
00:00In this chapter we'll take a closer look at two of the main components of Spry,
00:04Spry Effects and Spry widgets. Spry Effects are combinations of JavaScript and
00:09CSS that cause page elements to change appearance, size or position. They can
00:14be triggered by user interaction, and can help enhance user interactivity,
00:18transition elements from one state to another and increase the visual focus of
00:22a specific element.
00:23There are seven predefined effects in the Spry framework: Fade, Highlight,
00:28Blind, Slide, Grow, Shake and Squish. In reality these are just clusters of the
00:36core animator classes Move, Size, Opacity and Color, as you can imagine being
00:41able to change the position, size, opacity and color of elements on the page,
00:45it allows you to create some compelling visual effects.
00:48So here I have a summary of all the different effects, and we'll just go
00:50through them one by one and preview these guys. Now I have these effects all
00:54applied to div tags, and one of the thing you will notice, is some of the
00:58effects can be applied to just about any element, well, some are restricted to
01:02specific elements, and those are mentioned in the summaries.
01:05So the first thing I want to take a look at is the Appear/Fade, so if I like
01:08the click the Appear/Fade button, we can see that our targeted tag fades out.
01:12Now a lot of the effects can be set to toggle, and those like if I click again,
01:16it comes back, if you needed to toggle back and forth, most effects can do that
01:20for you. So I'll scroll down a little bit and we'll find Blind. Notice that
01:25Blind is going to roll that up or close it just like a window shade blind
01:28would, but I want you to notice something about the content, and as the content
01:32stays in place, while the Div tag itself collapses and expands.
01:37Next we have Grow and Shrink, and the interesting thing about Grow and Shrink
01:41is that you can set this from the center of the element, or you can do it as we
01:44are doing it here from the top left- hand corner. Notice that it affects both
01:47the content and element itself.
01:49Next we have Highlight, and what Highlight is going to do for you is, it's
01:53going to change color from one color to another. So you have the starting
01:56color, and you have the stopping color. In this case the starting color was the
01:59default gray, and the end color was the yellow. If I run the effect again,
02:03notice it does the same thing. A lot of people will use roller effect for
02:07highlight, and it can be really effective in rolling over one elements and
02:10having another element highlight.
02:12Next we have Shake, which is a fun little effect, it just kind of shakes it
02:15back and forth. We have Slide, now Slide is very similar to Blind. Notice this
02:20time though that the content also animates, so it's not just the Div tag itself
02:24that collapses, Slide literally moves to Div tag and hides the portion of it
02:28that is moving.
02:30And then finally we have Squish, Squish is a lot like Grow and it always
02:35animates from the top left-hand corner. Squish can also be set to toggle
02:39through Dreamweaver, you can do it through code, but you can't do Dreamweaver.
02:41So in order to see that again, I'll just refresh the page, and I can run the
02:45effect again.
02:47Used correctly Spry Effects can be a very elegant way of enhancing the
02:50interactivity and design of your pages, and as we'll see their ease of use
02:55makes them incredibly easy to implement them on your pages.
Collapse this transcript
Adding Spry effects
00:00Although adding Spry Effects through code is actually pretty simple and only
00:04requires a minimal amount of coding, if you are using Dreamweaver the process
00:08is even easier. In Dreamweaver you add Spry Effects through the Behaviors
00:12panel, just like any other JavaScript behavior. As you apply a Spry Effect,
00:16Dreamweaver will prompt you to set options that are specific to that effect.
00:20In this example we'll add the Blind Effect to three of our page elements to
00:24reduce their footprint, and add user activity to our page. Now before we get
00:28started, we are going to have to take a moment and redefine where Dreamweaver
00:32copies our Spry assets. Now if you've watched the earlier movie on managing our
00:36Spry assets, you know exactly what I'm talking about, and if you haven't, I
00:40recommend pausing this one, going back and watching that one again, so that you
00:43have a really good understanding of how Dreamweaver handles adding new Spry
00:47Assets to your site. What we are going to do, is we are going to tell
00:50Dreamweaver exactly where to place our new Spry Assets.
00:52So what we are going to do, if you are following along with me in the exercise
00:55files we are going to go to the 02_02 folder in our Chapter_2 folder I'm going
01:00to go ahead and right click that folder, choose New Folder, and I'm going to
01:03title it, SpryAssets. Notice that this is all one word, capital S, Capital A.
01:08Now it doesn't have to be named that, Dreamweaver can put these in any folder
01:11you want them to, we are just going to do that because it's a consistent naming
01:14that we'll use the entire class.
01:16Now I need to go and edit my site definition, and I can do that very easily by
01:20going over to my Files panel and double clicking the name of my site right
01:23there, spry_intro, and that brings up my Site Definition dialog box. I'll go in
01:28Advanced tab. go right down the Spry. And what I need to do now is I need to
01:33browse out to folder that I just created. So I'm going to go up to the
01:37Chapter_2 folder, 02_02 SpryAssets, I'll open that one and I'll select it.
01:45Any new Spry Assets that needed to be added to my site will now to be added to
01:48this folder, and this is the way that we are going to keep all that localized,
01:53so that we don't overwrite some of those Spry Assets stuff that we have already
01:55got in our site. Now let's see what we are actually going to do here, I'm going
01:59to scroll down towards the bottom of the page, and at above the page I see a
02:03couple of bios. There is me, there's my friend Danny, and my friend Greg, and
02:09these bios don't require a lot of scrolling, but it would be really nice if
02:12after they were done reading one, they can sort of roll it up to read the other
02:15ones, and Spry Effects are going to allow us to do that.
02:18So the first thing I'm going to need to do, is go ahead and give each of these
02:21elements an id. So if I click inside in my headline here James Williamson, I
02:26can see that the div that's around it has an id of jamesBio. And then Danny's
02:34is, of course as you would imagine, it's danBio, and Greg's is gregBio. That's
02:40very important, because as we are setting options for the Blind effect, it's
02:43going to want to know which element we are going to be driving.
02:46Now the next thing we need to do is, we need to figure out which element is
02:49going to serve as a trigger for it, and the natural trigger for this effect
02:52would be our headlines. So we'll do the first one by clicking inside the
02:56headlines James Williamson, and if you want you can use the tag selector to
02:59click on that, and actually select the h1 tag, although being inside it will be
03:03fine to, but I think you will be happy with results, you can go ahead and
03:06highlight that, and I'm going to go over to my Tag Inspector panel and click on
03:10the Behavior.
03:11So we find our Spry Effects in the same place that we find all of our
03:15JavaScript behaviors. I'm going to go ahead and click on the plus symbol, I'm
03:18going to get on the Effects, and I'm going to choose Blind. Each effect has its
03:24own set of options, but they'll look very similar to this. The first thing that
03:29it's going to ask you is, who do you want to effect? It doesn't have to be the
03:32element that you have selected, although that's the default.
03:34So I'm going to grab the pull-down menu and you can see any element that has an
03:38id I can go ahead and affect, and I'm going to choose jame'sBio. The Effect
03:42Duration is in milliseconds, and I'm going to make that a little faster, maybe
03:45500 milliseconds, so half a second, rather than a whole second. And I can
03:49choose either to Blind it up or Blind it down, and since we are starting with
03:53these open, I'll have a Blind up, and it can Blind from 100% to 0% or whatever
03:59you'd like that. Now 0% means totally hidden, and I don't want it totally
04:03hidden, what I would like to have, is just the headlines still visible.
04:07It's interesting, because you can mix percentages and make use of measurements
04:11like pixels. So I'm going to have it actually Blind up to 30 pixels instead of
04:1530%. It's nice, and then I want the effect to Toggle, because I want to give
04:20the person the ability to open and close them. So I'm going to click OK, and
04:25then this becomes extremely simple, because it's going to repeat it for the
04:28other two headlines.
04:29Now I do want to point out one thing before I do that, if you look in the
04:32Behaviors panel, you can see there is our Blind Effect and there is the trigger
04:35for it on click, if you wanted to, you could change that. So you could change
04:39that to a MouseOver or MouseOut. So you are not stuck with the default event,
04:43you can have any event that you want triggered at.
04:46All right, just go ahead and do it for the rest of these guys. So I'll go to
04:50Danny's headline, select it, go to Blind, make sure that we are effecting his
04:55bio, take that effect on the 500 milliseconds, and remember I'm going to change
05:01that to 30 pixels, and not percent and we'll toggle it. Third time as the charm
05:07we'll go ahead and do Greg, we'll Blind effect, make sure we are going the
05:14gregBio, do that at 500 milliseconds as well, give that a 30 pixels, and again
05:23toggle effect.
05:24Now I'm going to do is Save All and as soon as I do that, notice that it said,
05:30hey, you need an external JavaScript file to make this work, and I'm going to
05:35go ahead and copy this over. So notice where it's placing it. It is placing it
05:38in 02_02 SpryAssets directory and the reason it's placing it there, we told it
05:42to. And I'll go ahead and click OK and then preview that in my browser.
05:49Now if I scroll down each one of these and click on them, and notice they Blind
05:54right up. So also the toggle, so if I click on it again it extends. Now I truly
06:00believe and it's the little things that make a big difference, and you'll
06:03notice that the user is not getting any feedback whatsoever, that these
06:07elements are clickable. So the next thing we need to do is go ahead and take
06:10care of that really quickly. So I'm going to close my browser, and I'll go back
06:14to Dreamweaver, and I'm going to go into my CSS styles, and I'm going to look
06:19at all styles.
06:20Now we already have a selector that can help us out here. So I'm going to
06:24browse down, and as I go through, I can find #maincontent. galleryArticle
06:32div.bioContainer h1, so it's a long selector, but it's not too far down. Now if
06:38I click on this, I could double-click this to open it up and edit it with the
06:42dialog box, but I really like changing my properties down here in the
06:45Properties view. So I'm just going to come down here right below the list of my
06:49styles. I want to make sure that I have to show only Set Properties icon
06:53selected here down below that, and I'm just going to add a property. I'm going
06:56to add the Cursor property, you can grab that from a pull-down menu or if you
07:01are comfortable you can just type that in, and I'll hit Tab, and I'm going to
07:05type in pointer, perfect. Just do one more, Save All, let's preview that in the
07:11browser one more time.
07:14Now we are getting the feedback that says, hey, this is clickable, and when you
07:17click on it, pulls it up, excellent, exactly what we wanted to, how much code
07:24did that take? Let's go and find out. If I switch over to Code View, I notice
07:28that my h1 tag has a little bit of JavaScript that's responding to the click
07:34event. Let's find the MM_effectBlind and then if I scroll up to the head of my
07:39document, I can see that I have a predefined function right there that's
07:44calling the DoBlind function on this Spry Effects, and then I have the link to
07:49my external SpryAssets file and that's it. That's all it required.
07:53So the overall process for adding Spry Effects is the same for each effect. Now
07:57keep in mind that while the overall process for adding Spry Effects is the same
08:00for each effect, each one is unique and requires input that is specific to that
08:05effect. You should also note that occasionally certain options will not be
08:08available through Dreamweaver's Behaviors interface, and will need to be added
08:12through code if you need them. Truthfully, while our Blind effect is adding
08:15some spice to or bio capsules, by themselves they are a bit lacking, they
08:18aren't communicating with each other at all, opening and closing one of them
08:22has no effect on any of the others.
08:24In that case we might be better off using a widget. widgets are more complex
08:29interactive structures that allow us to display related data in a visual and
08:33interactive component. Before exploring using a widget for our bios, we should
08:37take a moment to discuss widgets in greater detail, and we'll do that next.
Collapse this transcript
Spry widget overview
00:00Spry widgets are user interface components that allow you to display content in
00:04small spaces, enable navigation and increase user interactivity.
00:09Although all Spry widgets have unique structure and interactivity, they all share a common
00:13makeup of clean, well-structured XHTML, element-specific CSS and interactive
00:20JavaScript functions that control interactivity and behaviors.
00:23This consistent structure makes it easy to work with all widgets after learning
00:27the basics of using and modifying them. Within the Spry Framework each widget
00:31has its own set of unique CSS and JavaScript files. If you insert one of these
00:36widgets using Dreamweaver, Dreamweaver will automatically link these files to
00:40your page to control the widget's functionality and styling.
00:43From that point, you can modify the content the same way you add any XHTML to
00:48the page. You can control the appearance of the widget by modifying the related
00:52CSS. So before we get into inserting a widget on our own, I want to do a brief
00:56overview of the widgets that are available through the Dreamweaver Interface.
01:00Each of these widgets are presented here using their default styling and
01:04makeup. So if you put one on the page, this is what you'll see before you
01:07modify it. So the first one I want to take a look at is an extremely popular
01:10one. It's the Spry menu bar. So if you ever wanted one of those pulldown menu
01:16systems that you see everybody having and that are CSS and JavaScript-based,
01:20you can just grab one of those by inserting this widget and you can have as
01:24many nested menu structures as you want with this. This is just the default one
01:28that kind of shows you what's possible.
01:29If I scroll down a little bit, we also have our Tabbed Panels and it allows you
01:34to display content from one panel to the next. There is a really nice way of
01:39showing a lot of content in a small space. Now if you want a more interactive
01:43take on that we have the Accordion widget.
01:45The Accordion widget lets you have some panels as well, but these panels slide
01:49and animate up and have different focus states that you can respond to as well
01:53as hover states. So that's pretty cool. We also have the Spry Collapsible
01:58Panel, which is much like an Accordion widget, but it's just a single panel.
02:02Also, notice that you're basically blinding that panel up or down using the
02:06Blind effect. So you can see it's a combination of structure and effect.
02:10Finally, we have one of my favorite widgets, the Tooltip widget. With the
02:13Tooltip widget you have a trigger element on the page and then when you hover
02:16over that, you get to see the Tooltip content and the Tooltip content can be
02:20anything you want. Notice that the default content is just some text but it can
02:24be images, and really anything we want to put in it. So you can do some really
02:28creative, cool things with the Tooltip.
02:30The great thing about using Dreamweaver to build Spry widgets is that it does
02:33the heavy lifting for you. As a designer you can focus on styling and layout
02:38and let Spry handle the functionality and structure behind the widget. It
02:42should be noted that not all Spry widgets are available through the Dreamweaver
02:45interface and require minimal hand coding to insert into your pages.
02:49For more information on all of the Spry widgets, be sure to explore Spry's
02:53online documentation.
Collapse this transcript
Adding Spry widgets
00:00Now that we've spent some time examining the Spry widgets available in
00:03Dreamweaver, let's add one to our site. The About page that we looked at
00:07earlier contains the bios of the three founders of the Desolve.org site. In a
00:12previous movie we added a Spry effect to increase user interactivity with our
00:15bios. Although, the effect looks good, the way that it is currently applied
00:19isn't as coherent as we'd like it to be.
00:22Interacting with one element does not affect the remaining elements at all. To
00:25create a more intuitive user experience, we'll replace the effects with a Spry
00:29widget. Often, deciding on which widget to use in a specific instance requires
00:34careful thought. In this example, we have three bios that we would like to
00:38display in a shorter space and also add some interactivity to encourage users
00:43to read them.
00:44While the Tabbed Panels widget would work well here, the Accordion widget
00:47features a series of collapsible panels, which use the same animation we had
00:52applied by using the Blind effect. Since that's the animation we want, we'll go
00:56with an Accordion widget.
00:57Now before I get started, we've got to manage our S Spry assets again. So I'm
01:01going to go over to the 02_04 folder, I'm going to right-click and create a new
01:08folder and I'm going to name this new folder SpryAssets. Now again, if you
01:11haven't viewed the movie on managing our Spry assets I would highly encourage
01:16you to go back and do that again so that you understand exactly why we're doing this.
01:20The next thing I'm going to do I'll double-click the name of my site here,
01:23spry_intro. That will take me to the Site Definition dialog box and once again,
01:28I'll go down to Spry, and then we'll browse out to our newly created SpryAssets
01:33folder. Remember this is in the 02_04 directory, SpryAssets, and if you're
01:39following along with me at home with other files, just make sure that you have
01:42an empty folder in someplace, it doesn't need to be named SpryAssets, that you
01:46can copy those assets over to.
01:48Okay, time to insert our widget on the page, I'm going to scroll to the point
01:51where we have this headline that says, Our founders and I'm just going to click
01:54right after it. Most Spry widget structures are based on Div tags so you don't
01:58have to create an empty line for them, they are block-level elements. They will
02:01exist in their own space, you just need to insert your cursor right at the
02:05point that you want them.
02:06So I'll go up to my Insert toolbar and find the SpryAssets and the widgets are
02:10found on the right-hand side. Here we have all our widgets and we're going to
02:15find the Spry Accordion widget. It's the third widget over from the left one
02:19there in the middle. I'm going to go ahead and click that and just like that we
02:23have a Spry Accordion widget on our page. Now we have three bios, so we need to
02:28add a panel and it's incredibly easy to do.
02:30Now if you have ever lose focus on your widget and you want to get those
02:34properties back on the Properties Inspector, simply mouse over your widget and
02:38when you mouse over it, you'll see a little tab, click on the tab itself. That
02:42focuses on the widget Properties and not on the Properties of the contents,
02:46like the Div tag or the heading or the paragraph that you might have inside of it.
02:49Well, one of the things that we can do with our Accordion widget is add panels.
02:53So I'm going to go ahead and add one more panel, and notice that it adds the
02:57panel where you placed it. So we've got Label 1, Label 3 and Label 2. That's
03:01another nice thing about this, you can reorder these. So if I select Label 3,
03:05notice that I hit the Down Arrow and have it go down.
03:09So we're just looking at the default content right now. Editing and working
03:12with your Accordion widget can be a little tricky. You'll notice that whatever
03:16panel I select in the Properties Inspector, I can see the content in that
03:20panel. But if I'm focused someplace else and I click back in it, it's not quite
03:24that easy. Notice if I click to any of these labels however, there is this
03:28little Visibility icon that shows up on the right-hand side. If I click that,
03:31that will help me show the panel content.
03:34Now in reality, if I were looking at this in Code View, I can see that our
03:37widget is merely a collection of Div tags. That's all it is. There is no smoke
03:41and mirrors there. So one thing that I could do and actually it's one thing
03:45that, I think, I'll do is I'm going to go to my Document toolbar, right-click
03:51to open up my Style Rendering toolbar and I'm going to turn my Style Rendering
03:55off. By doing that, I have much easier access to the labels and the content.
04:01So what I'm going to do now is I'm just going to copy and paste. So I'm going
04:04to copy all the content from each of my panels and I'm going to copy the
04:09headlines, the name of the person and put that in place of the label and then
04:14the content itself including the image and the text, I'm going to paste in the
04:19Content regions. So just go through, copy each of the headlines and paste them
04:26into where the labels are. Then copy the contents of the images and the text
04:37and replace the placeholder content.
04:42You can see how much easier this is with Style Rendering turned off because we
04:46don't really have to worry about navigating that widget structure. There we go,
04:54and as soon as you're happy with that, go ahead and save the file. Now you're
04:57going to get a message here and Dreamweaver is going to tell you that the
05:00Accordion widget's CSS and JavaScript files are going to be copied over to the
05:05default directory, or in this case, the directory that we have defined for it.
05:09So click OK, let's copy those over there.
05:12Now we need to do one more thing here and, by default, these panels don't
05:18really have any formatting going on inside of them. So I'm going to format each
05:21of the labels as a Heading 1 and then I'm going to make sure that the text is
05:26formatted as paragraph. So I'm going to do that for each one of those. So the
05:30name is going to be Heading 1 and then make sure that the text itself is
05:35formatted as a paragraph.
05:37All right, great. So once again I'm going to do a Save All and then I'm just
05:49going to preview that in my browser to see what we have going on now. If I
05:53scroll down, well, look at that. All right, well, our Accordion widget is
06:00behaving the way we want it to, but the styling is way off. We've got existing
06:05styles competing with and overriding the added Spry styles, and the default
06:09styles themselves, they are not exactly what we want either.
06:13So clearly, there is still work to do here. So our next job is to begin styling
06:17the widgets so that it integrates into the design of our site.
Collapse this transcript
Styling Spry widgets
00:00If you are a designer, one of the best things about the Spry Framework is its
00:04reliance on technologies that you probably already know. In the case of our
00:09Accordion widget, it is functioning properly but the styling is a bit of a
00:12mess. Fortunately Dreamweaver has linked an external CSS file to our page that
00:17controls the styling of our widget and is just as easy to update as any other CSS file.
00:23First, we'll start the container elements that make up our widget and then
00:26customize it by adding styles specific to this widget. So if I scroll down we
00:31can see -- well that's a mess. We can't even see half the content, the image is
00:36kind of that erect, the text is all over the place, the colors aren't doing
00:39what they're meant to do. Not so good.
00:42Also I'm going to preview this using the Live View. This is a really cool new
00:44feature in Dreamweaver CS4 and that allows me to kind of preview some of the
00:50styling. Now I do want to point out that it's not always 100% accurate. So,
00:55never ever fear previewing that in the browser as well. I definitely recommend
01:00that, because notice that in the browser we see that we have a focus class too.
01:05We've to decide whether we really want it look different from when it's not
01:09being focused versus focused on. So there is a lot of decisions to be made here
01:13about the styling. Well, back in Dreamweaver, I'm going to turn off Live View
01:18and what I'm going to do is just modify my interface a little bit, so I have
01:21got a little bit more room to code and see what's going on on the right-hand side.
01:25I am going to collapse my panels down at icons, which -- I love that new
01:29feature. I'm going to use a Split Screen View, so that I can see the design on
01:35the right-hand side and the code on the left-hand side. So, what I have is I
01:40have the Split Vertically View turned on and I definitely recommend working that way.
01:44Well, we'll be using another new feature of Dreamweaver CS4. See how it
01:47affected my word flow. Right up underneath the about.htm I have got a listing
01:51of all the related documents. I click on the SpryAccordion.css and this is our
01:57first look at one of the CSS files that drives the widgets.
02:00Now, one of the things that I really, really like and admire about the way they
02:04put these together, is they are extensively commented, so we can go through and
02:10read about what each one of these selectors is doing, how it's controlling the
02:15element and some of the dos and don'ts of the specific rule. So if it's the
02:20first time that you modify one of your widgets, I definitely recommend reading
02:23through that very, very carefully. Now it is causing a little bit of extra
02:27spacing. So if you wanted to deploy it by getting rid of comments,
02:30that would be fine as well.
02:32So let's take a look at some of the rules that we're going to change. I'm going
02:35to scroll down and I'm going to find the AccordionPanelTab. This is a class.
02:42Most widgets are class driven, the classes are dynamically assigned to the
02:46elements inside the widget or they're manually assigned as the widget is
02:49created, either way.
02:51In this case this class is controlling the individual tab themselves. So we're
02:55going to do a slight change here. We're going to change the background and I'm
02:59going to change it from background color to just background. That will allow me
03:02to add an image later on. I still use shorthand notation and I'm going to
03:06change the color to 999073. So that's more in alignment, what we're doing with our site.
03:14I am also going to change the border. I'm not going to do a border on top and
03:18the border on bottom, I'm going to change a little bit. I'm going to leave it
03:21at solid at 1 pixel but I'm going to change the color and the color is going to
03:25be #5d5743 again, more in alignment what's going on with our site.
03:34Now I'll scroll down to the next rule and our next rule that we're going to
03:38change is the AccordionPanelContent. So this is the region where the actual
03:42content is sitting, notice that it has an overflow of orders, so that you can
03:46scroll bars the content that no longer fits into it and notice that we also can
03:49change the height of our panel here as well. So we can set that if we needed
03:53our panels to be taller or shorter.
03:55So I'm going to go in and add a background attribute to this. I'll go down the
03:59next line, add a background attribute and we're just going to color initially
04:02so #D2CEC1. So there is our background color for our AccordionPanelContent. Now
04:15if I scroll down a little bit further, I can see that here we have
04:18AccordionPanelOpen, AccordionPanelTab.
04:20So one other things that we notice is that AccordionPanelOpen is referencing a
04:25specific state of the widget. So this would be a dynamically assigned class
04:29that as the widget is running, JavaScript could go ahead and assign this class
04:33whenever it's open. So, that way we can style the different states of the
04:36widget individually as well which is pretty cool.
04:38Now here we're just going to change the background color of this. Let's make
04:41that 999073. So keeping that color consistent. If we scroll down a little bit
04:47further we can see that we have the AccordionPanelTabHover and the
04:51AccordionPanelOpen. AccordionPanelTabHover. So this is when you're hovering
04:55over the panel whether it's open or not. We're going to give that actually the
04:58same color, just the way that here it's going to be a different color.
05:00So here I'm going to do 4B4739. Feel free to use your own colors obviously and
05:08we're going to replicate that down to that 4B4739. Just a couple more to go.
05:17One thing I'm going to do, the focused AccordionPanelTab, I actually don't like
05:21the effect of giving it a different color when you're focused on it and I think
05:24it ruins the aesthetics of what we're going to do.
05:25So I'm going to take that rule and using my Cutting toolbar I'm going to go
05:29ahead and comment that out using a CSS based multi-line comment. It basically
05:34just turns that style off now. Now, why not delete it? Well because if I decide
05:38later on that I actually do want that, there is that rule just sitting in there
05:41really to be reactivated and changed. So that's nice.
05:45Then finally we're going to change the background color of our
05:48AccordionFocused, AccordionPanelOpen and for that one we're going to do 4B4739.
05:53You'll notice that we're using very consistent colors all the way throughout.
05:59So I'm going to do a Save All there and then we'll preview that in our browser.
06:06If I scroll down into my widgets, here we go. All right. So color you can see
06:11is now little bit more consistent with our site. Although the rest of it
06:15doesn't look exactly the way we want.
06:16So our basic styling is out of the way. We've modified the widget, so this
06:20color scheme matches our site and so that the interactive element are styling
06:23the way we want, when the widget animates. The only thing left to do is
06:27overwrite the site wide styles that are causing some formatting issues with our
06:30headlines and things like that. And then add a little user feedback and
06:33accenting through the use of some simple background images.
Collapse this transcript
Customized widget styling
00:00By exposing the structure and styling of Spry widgets so clearly, Adobe has
00:04made it easy to not only change the default styling of your widgets but to add
00:08to and customize your styling as well.
00:11Currently our Accordion widget's default styles have been changed to be in line
00:14with our site design, but our overall site styles are causing the contents to
00:18not look the way we need them to. In this exercise, we'll take care of our
00:22widget's content by overwriting our site styles and we'll add to the usability
00:26of our widget by using background images to give the users feedback on
00:29various panels and their states.
00:32So here we have the about.htm file open from the 02_06 folder and we're just
00:37picking up where we left off but before we get into the styling,
00:40let's figure out exactly what's going on here. You can see our headings are way too big
00:44and if I use our Code Navigator, and I can get that by holding down the Alt key
00:48and then clicking on the element,
00:51we get a nice little cascading set of rules that tells us exactly who is
00:55applying in the bottom rule is the one that is taking the precedence over
00:59the rules further up the list. So you can see that our SpryAccordion external files --
01:04well, these are all class based. So that's pretty low in terms of specificity,
01:07whereas our main.css, we get this rule all the way down here in the bottom
01:11#mainContent.galletyArticleh1.
01:14So we can tell for that particular element that is a really specific selector,
01:18so it's going to be overwriting some of our other stuff. So if we want to
01:21change the styling of these elements inside of our widget, we're going to have
01:23to write some selectors that are little bit more specific than the default
01:27selectors and there is nothing wrong with doing that.
01:29So, I'm going to go and collapse my panels down the icons. I'll click on Split
01:34Screen view and reposition my widget so that I can see it, so that I can see
01:38how my styling is going to be affected. If I go into the SpryAccordion.css,
01:43I'm going to scroll all the way down at the very bottom of it. I'm going to add
01:47some user-defined styles here and I'd like to separate those from the default selectors.
01:52You don't have to. You can put them anywhere you want to within the external CSS,
01:54but it's a nice idea to do this so that later on you can remember that
01:59these are author defined styles. You'll notice that I'm going ahead and placing
02:02in a comment that lets me know that these are author defined styles. I guess
02:07I should pluralize that.
02:08Again, a year from now or three months from now, I might not remember that
02:11those are not a part of the default styles that come with this widget that I
02:14added there. So I want to be very specific about that. Let's go ahead and take
02:18care of our Heading 1 first. I'm going to type the #mainContent, space, .galleryArticle,
02:27space, .AccordionPanelTab h1. Now, notice how specific this is. It's targeting any H1
02:39inside of Accordion panel tab, inside Gallery Article, inside Main Contents.
02:43It's a very specific rule.
02:44Also notice that if you are like me and you use camel case naming a lot,
02:48the Spry class names are all capitalized. So that's something you're going to have
02:52to remember if you're writing selectors for those. I'm going to down to the
02:55first line. I'm going to set my color to be #FFF. I'm going to set my font size
03:01to be 1.4 ems. I'm going to set my text align to left and anything after
03:08the first two rules, we're really just sort of overwriting what we don't like in
03:12the earlier Heading 1. And then I'm going to do padding right.
03:15So we're taking off some of the padding that's on here, 0 pixels. Then finally
03:20I'm just going to do a margin of 0 as well and save that. If I click back
03:26over here in my Design view, you can see that I've sort of reset those headings
03:29and they look much, much better now. All right let's keep going.
03:31I'm going to click back into my CSS and let's do #mainContent, space, .galleryArticle,
03:40space, .Accordion, so it's going to go a little different, panelContent.
03:45Instead of the tab, this time we're focusing on content. Space, img.
03:50So now we're targeting the image inside of our content tabs.
03:54Here we're going to set display to inline and what that's going to do for us is
03:59overwrite the default block formatting that's been applied to it. Then we are
04:02going to do a float to the left and that will help wrap the text around it and
04:06finally, we'll give it a little bit of a margin and our margin's going to be
04:090 pixels for the top, 10 pixels for the right-hand side, 0 for the bottom and
04:15finally 0 for the left. So just a little bit of right margin on that, so that
04:19the text will wrap around the image, looking much better.
04:21I am going to go ahead and do one more of these. So we'll do #mainContent
04:26.galleryArticle .AccordionPanelContent and then finally P for paragraph.
04:34So we're targeting the paragraph inside of the panel content this time. And for
04:39that one we're going to set a margin- top of 20 pixels. We're going to set our
04:44font size, 2.9 ems, and finally we're going to set line height to a multiple of 1.4,
04:52save that. If we preview that in our browser we can see that
04:57the formatting of our Accordion widget is looking so, so much better.
05:02We're not totally done with it yet. I mentioned that I wanted to add little bit
05:04of accenting to that. So, up in the headlines we're going to have a background
05:07graphic for the tabs that identify the current state of the widget and help the
05:13user know that there is another state down below it. So let's close that.
05:17What we're going to do now is we're going to go ahead and modify some of the
05:20existing selectors for our tabs to put the background images inside of them.
05:24But before we do that we'll add little bit of padding. So I'm going to do
05:28padding to the left of my H1 selector and we'll do 70 pixels. Now what that
05:32will do for us is it will sort of move the heading over a little bit and
05:35give room for our background image, which is exactly what we what.
05:38Now let's go and add our background graphic. So I'm going to scroll all the way up
05:43and find my first AccordionPanelTab, there it is. And we're going to modify
05:47the background property. Now be very careful. Make sure you're modifying
05:51background and not background-color. That's the default that comes with this.
05:55So make sure that's been change; if it hasn't you are going to want to change that.
05:59So right after the color, I'm going to type in 'u', that gives us the little
06:02URL code hinting and if I hit Enter, I can now browse for my image which is a
06:06mush faster way of finding it. And we're going to look in the 02_06_images
06:11directory and you want to choose this accordion_tab.gif.
06:16Now, notice that this is one graphic that has all four states of my background
06:20image on it. So instead of doing four separate graphics, we're just doing the one.
06:24That lowers the overhead a little bit and then when we want to display
06:27another one, we just simply move its position in with that rule. That's very
06:31easy to do. So we're going to highlight that, click OK.
06:34Now, we need to set that position. So I'm going to type in no-repeat, so
06:38we only get one of these and then I'm going to type in left and then choose top.
06:42Now that is the default, but I just want to be very explicit with that since we're
06:46going to be moving that position around. So I'll save that if I click back,
06:50I can now see that tab. So that looks great. It looks perfect.
06:52I am going to scroll down a little bit and I'm going to find my
06:56AccordionPanelOpen AccordionPanelTab and this is exactly what I was talking about.
07:00I'm going to get rid of that background color so that just says
07:02background. Now, I learned by mistake last time, so this time instead of
07:07having to re-type that or re-browse for that, I'm just going to copy what we've got
07:11and paste that into that because all we're changing is the positioning.
07:16So, I'm going to change left top and for this rule, we're going to get a little
07:20explicit here. We are going to do 0 pixels for horizontal and then a space and
07:24-44 pixels for vertical. Very nice, keep scrolling down.
07:30Find the AccordionPanelTabHover and inside that I'm going to do a paste and this one
07:36instead of being left top, just going to go up a little further. I'll go 0
07:39pixels for horizontal and then -88 pixels for vertical, perfect!
07:44Now scroll down little bit and you'll find the AccordionFocused,
07:47AccordionPanelOpen, AccordionPanelTab. It's a long one but that is exactly what we need,
07:52so we'll go ahead and paste that in there as well. This time we're going
07:55to change left top to left and then bottom. So we'll save that as well.
08:00All right let's go ahead and preview that in our browser. Now we can see all of our
08:05different states and if we click, we can see that the background images are
08:11responding to this quite nicely. Very good! So that is exactly what we want.
08:16Now, if you are new to using Spry, you might be a little intimidated by these
08:20widgets initially, but they are very easy to use, easy to update and extremely
08:24easy to customize. There are no rules that prevent you from modifying the
08:28existing CSS, structure or even the behaviors of your widgets, if you are fluent in JavaScript.
08:33Now keep in mind that widget structure and functionality are tied together. So
08:37before committing to any major changes in structure or styling, be sure to test it thoroughly.
Collapse this transcript
3. Building Navigation Through Spry
Planning for drop-down menus
00:00One of most common questions that I get from students in my classes is how to
00:04build the CSS based drop-down menu for their site's navigation. Well, there is
00:08no shortage of techniques on exactly how to build drop-down menus. Each one has
00:13its own pros and cons in terms of accessibility, cross browser reliability and
00:18functionality.
00:19Most techniques involve combining CSS and JavaScript to build the drop-down so
00:24its no surprise that most Ajax frameworks include libraries for building these
00:29types of menus, surprised, no exception. And the Spry menu bar widget is among
00:33the easiest to deploy and modify.
00:36In this chapter we'll examine the Spry menu bar widget in detail. First looking
00:40at the basic structure and styling of the widget and then customizing its
00:44appearance and functionality for our own site. Before we get into examining the
00:48Spry menu bar, however I would like to take a moment to discuss the factors
00:52that should be considered when deciding whether or nor to deploy drop-downs on your site.
00:57While there is nothing inherently wrong with using such a menu structure, there
01:00are many factors that need to be considered before committing to it. Many user
01:04agents do not support JavaScript and indeed many users will disable it for
01:08their own browsers. In such an environment having your navigation solely rely
01:13on JavaScript to function properly is a recipe for disaster. At a minimum you
01:18should have alternate content to serve to client agents that are not JavaScript enabled.
01:22Before we embark on the journey of creating our own drop-down menus. Let's take
01:26a look at how a very popular site utilizes them and plans for non-JavaScript
01:30enabled clients. So here we are on one of the webs more popular sites. And if I
01:36look at the menu navigation, if I roll over these, we can see that there are a
01:40lot of different links here. Of course the top-level links are not clickable
01:45and normally that would be a no-no in terms of accessibility. But what's really
01:50nice here is the implementation of non-JavaScript enabled navigation.
01:55So I'm going to go up to my browser Options and I'm going to disable JavaScript
02:00and Reload the page. Notice that the this particular client agent did not have
02:05JavaScript enabled, its serving up an entirely different secondary menu that
02:10has all of the main links and secondary links exposed. So there was a lot of
02:14thought that went into this.
02:15So usually when I'm advising students or clients about Ajax driven navigation,
02:20I recommend asking certain questions about the navigation. First, are the
02:24secondary links crucial to the goals of the site? Second, are there enough
02:28secondary and tertiary links to justify drop-downs? Third, is there a
02:32compelling reason to expose these links and drop-downs beyond the it-looks-cool
02:37reason? And finally, if the client has decided to move forward with the
02:40drop-down based navigation system, is there a plan and place for serving
02:44alternate content when JavaScript is disabled?
02:47There are always multiple design decisions that are made when it comes to
02:50navigation. But never lose side of the fact that usability and accessibility
02:54should be the driving factors behind the navigation of your site. In some cases
02:59drop-down menus can make the site more usable by making the navigation simpler
03:03and easy to access. In other situations it can harm usability. So careful
03:08planning and consideration should go into any decision concerning using them.
Collapse this transcript
Examining the Spry menu bar widget
00:00Much like the Accordion widget we worked with earlier, the Spry Menu Bar widget
00:04is easy to insert and easy to modify. Because of the important role that
00:08navigation plays in your site, it's crucial that you understand the structure
00:12and functionality of the Menu Bar widget before deploying it.
00:16In this movie we'll examine the default menu bar before attempting to modify it.
00:20That way we'll have a much clear understanding of how its basic styling and
00:24structure work before we add to it or change it in anyway.
00:27The only thing I have modified on the default menu bar are the menu options
00:31themselves. So if I click on the Spry Menu Bar tab right there, I can see that
00:35I went through the Properties and added a couple of links to this and the
00:39submenu. This will be the menu bar that we're going to be using for our site.
00:43So if I Preview this page in my browser, I can see that my drop-down menus are
00:48working just fine. All of my hovering attributes are showing up perfectly. So
00:53right now, working just fine. Just a little bland I would say.
00:57So let's go back to Dreamweaver and let's take a look in the Code View so we
01:01can see exactly how this menu bar is being created and structured. So I'm going
01:05to switchover to Code View. At the very top of the document, I can see in the
01:09Head tag I've got two tags that are bringing in my external assets that are
01:15necessary for my menu bar. We've got the Script tag that's linking out to the
01:18SpryMenuBar.js and we have a Link tag that's linking out to the external CSS
01:24file, SpryMenuBarHorizontal.css.
01:27So you if you choose a vertical menu bar, you're going to get the vertical style sheet;
01:31if you choose a horizontal menu bar, you're going to get the horizontal style sheet.
01:34If I scroll down to the actual widget itself, you can see that really all it
01:39is, is a series of nested unordered lists. So that's it, an extremely simple
01:46structure, and this is something you could very easily hand-code yourself.
01:50Also, notice that we are passing along some classes to identify what type of
01:54menu bar it is and to identify the Submenu items as well. Very simple widget
02:00structure here, just XHTML with a few class attributes identifying the
02:04different elements.
02:05Finally, at the very bottom of our code, we'll find another Script tag, where
02:09we have a constructor function that's actually creating the menu bar itself.
02:13There are a couple of options being past into that, that are very noteworthy.
02:16Notice that we have graphics that identify the Down and the Right, so to let
02:21people know when a menu is being dropped down and when a menu has available
02:26content, those little tiny errors.
02:29You can change those. You will notice that currently those graphics are found
02:32in the SpryAssets folder. Now, most of us would probably move them to the
02:36Images Directory and you'd need to update this here as well. So keep that in
02:40mind, if you don't like the graphic that they're using, you're free to use your
02:44own, just type in what you would like and you will get exactly that graphic, so
02:48that would work perfectly.
02:49As for the CSS; let me switch back to Design View, and I'm going to turn on
02:54Live View so that we can preview this within the Dreamweaver interface.
02:57What I'm going to do is drop-down one of the Submenus, and I'm going to hit F6.
03:01That's going to freeze your JavaScript for you, in that way this state will
03:04remain active. So now that I've got this drop-down menu pulled down, I can hold
03:09down the Alt key, the Option key on the Mac, and click to get my Code Navigator.
03:14So I can see within the SpryMenuBarHorizontal.css file that I have a lot of
03:19class selectors dealing with the different elements inside my menu bar. Now,
03:23I'm going to click on one of those, so that we can jump into the
03:26SpryMenuBarHorizontal page. I'm going to scroll down through some of these styles.
03:31There aren't a ton of styles in here, but there are some very important things
03:35going on. You'll notice that almost all of these have a Positioning Attribute.
03:38A lot of the Positioning Attributes are Absolute Positioning. We have left
03:43values, we have z-index. So there is a lot of CSS based positioning going on
03:48here. If you're not very familiar with the concept of controlling positioning
03:52through CSS, you want to be very careful about modifying any of those values,
03:55because they directly affect the functionality of your menu bar.
03:58I'm going to hit F6 to unfreeze my JavaScript, as a matter of fact, I'll just
04:02go ahead and turn Live View off.
04:05One last thing before we move on to inserting our own Spry Menu Bar, you
04:09definitely want to get extremely comfortable with the structure of it, and one
04:12of the best places to do that is in the online Spry Documentation.
04:17If you navigate to the homepage and the Spry Documentation, which is
04:20labs.adobe.com/technologies/spry, you'll find a link to this page, which is the
04:26specific Help page for the Menu Bar widget. They go through every single
04:30element of the Menu Bar widget in great detail. So if you read through this,
04:34you'll have a better understanding of it, than probably 90% of the people that
04:38are actually using it.
04:39There's one specific thing I want to show you in this file. I'm going to scroll
04:42all the way down to the bottom of the page to show you this. Here they have a
04:50list of the different styles, what they're controlling, and what you can do to change them.
04:55So if you're looking for a little primer in terms of, what I can change to
04:59affect the visual design of my menu bar, this is a great list here. Notice that
05:04they're focusing on the vertical menu bar, here but they also give you the
05:08horizontal menu bar item as well, and that's really just the only change
05:12between the two of them.
05:13So that's a nice little list that you can go through and kind of figure out
05:16exactly what you can't change and what you can change, that sort of thing.
05:19So before you attempt to customize your Spry Menu Bar, you really should make
05:23sure you understand exactly how the CSS rules are controlling positioning and
05:26styling. It's very easy to adversely affect functionality or trigger some cross
05:31browser compatibility issues when modifying the source style, so you want to
05:35test thoroughly as you begin installing your menus and you definitely want to
05:38come online and check out some of the reference so that you really thoroughly
05:41understand the menu bar before using it.
Collapse this transcript
Inserting the Spry menu bar
00:00Obviously, the first step in working with any Spry widget is to insert it on
00:04the page. In this movie, we'll start creating our site navigation by inserting
00:08a Spry menu bar on the page and editing it to match the structure of our navigation.
00:13I always find it helpful to know where you are going, even if you are going on a path.
00:17So what I have here is I have the finished Spry menu bar opened up.
00:21This want it is going to look like at the end of the chapter.
00:23So our menu looks just the way it normally looks, but when I get to the About
00:27and to the Shop, we have- you know not pull-down menus in this case, but fly-up menus.
00:32So, as the other thing you can customize these menus as well.
00:35And you can see that our menu structure is working -- well, relatively well there. Nice.
00:40So that is what we are going to be creating. So to get there, we first have to
00:44insert it on the page.
00:45So I'm going to go back to in the Dreamweaver and now I have the index.htm page
00:50open. So here is our page with absolutely no navigation on it. So we need to go
00:54ahead and insert our Spry menu bar. Before we get start with these steps
00:58themselves, we are going to have to be a little bit more managing of our Spry Assets.
01:00So you can see over on my Files panel, we are looking at the 03_02 directory.
01:05I am going to go ahead and create a brand new folder there.
01:08Once again it's going to be the SpryAssets folder. We are just keeping our consistent naming
01:12convention all the way through. We'll double-click the name of our site to go
01:15into and edit our site definition. I'll click on Spry and for the default
01:21location where the Spry Assets are being copied, I'm going to point that to the 03_02.
01:27So, Chapter 3, 03_02 and there is the SpryAssets folder I just created.
01:32So we'll choose that folder and then click OK. So now, we are sure that when we
01:37insert our Spry menu bar that the Spry Assets would go in the proper place. So
01:40once again we are just managing our Spry Assets a little bit here before we get started.
01:44Now there is a lot of CSS controlled layout going on here. So rather than trying
01:48to do this in Design View, I'm going to switch over to Code view. And what I
01:51want to do is place my cursor right after the heading 1 tag in the header on
01:56line 19. Fell free to create a blank space in the code, if you would like or
02:00you can just place right after that. It does not really matter.
02:02At this point you can also go back into the Design view too if you want to see
02:05what's going to happen here. That way you can physically see what is going to
02:09be happening. You know your cursors are in the right spot. You just do not want
02:11click anywhere else. You want to maintain focus at that point of code.
02:14Okay, I'm going to go up to my Insert toolbar and I'm looking at my Spry
02:17Objects. I want go to the first widget available to me, which is the Spry menu
02:23bar. I would go ahead and click on that. The first thing it wants to know is,
02:26"Hey, do you want a horizontal menu system or you want a vertical navigation system?"
02:30Well, we are going to choose Horizontal and then we are going to go ahead and
02:33click OK. So, you will notice that the very top of my screen now, we have our
02:39drop-down menu. Now if you are noticing that lot of styling is already taken
02:43place here. Well, we do have some existing menu styles that were styling the
02:46old navigation system and some of those we are going to have overwrite change,
02:50but some of them are going to exactly what we need them to do so.
02:53When we get into styling, we'll discuss those in little bit more detail. What
02:56we are more interested in right now, is going ahead and populating our menu and
03:00making sure that it has what we need in it. Right now it says the Item 1, Item
03:042, Item 3, Item 4. So again, if you hover over any type of the widget that you
03:09have properties that you can modify. You will see this little tab show up and
03:12clicking on that will populate the Properties Inspector with all of those
03:15different properties and values.
03:17So the first thing we are going to do is we are going to name our menu bar. So
03:22I'm going to go ahead and highlight on the menu bar here and name that mainNav.
03:25You will notice that occasionally it will jump you down the page. That's really
03:30not hurting anything. You just want to be able see it, so I'm going to scroll
03:33back up. Now, I'm going to control each of these individual items.
03:37Well, the panes that you are seeing here are the different systems of sub-menus
03:40that you can have. The first pane on the left is your Main Navigation Items.
03:44Then the middle pane gives you your drop -down menus for that particular one and
03:48then if you were to need another sub- navigation system, you can go ahead and
03:52add that to that one as well.
03:54So what we are really just seeing is the nested list. Well, our first item,
03:58click on Item 1 on the left-most pane here and the text over here reads Item 1.
04:02I'm going to change to the word Home. You will notice that it updates that
04:05within a menu itself. Then for the link I'm going to type in index.htm, notice
04:11that we do have the ability to browse.
04:12I might go in and give that a title as well. I'm going to title that Our
04:16homepage. I'm a big believer in giving your links titles because it really
04:19helps out with accessibility. For Home, we do not need any drop-down menu item.
04:23So I'm going to go ahead select these and one other time, highlight them and
04:26click the minus symbol so that they are gone.
04:29So we'll just go through all of our menu items in order. Item number 2, I'm
04:33going to select that. Its text is going to be Galleries. Its link will be
04:38galleries.htm. It's too bad that you do not have the point to file icon, that
04:42would be extremely nice, but as it is typing these inner heading browser really
04:45not that bad.
04:47The title for that one going to be Visit our photos. Maybe that's something
04:52they will put in later versions of Dreamweaver. And I'm going to click on Item
04:573 and this one is going to About and the link will be the about.htm and title
05:05will be Learn more about us. Now this one does have some sub-menu Items.
05:12So what I'm going to do now is go over to this middle pane, click on the first
05:16one which reads Item 3.1, and the text for this one we are going to type in
05:21Contributors. And that's going to link contributors.htm and the title for that
05:29one is going to be Meet our contributors. Now Contributors does not have any
05:35sub-menu items. So I'm going to go ahead and select those and delete them.
05:38Again the default one is sort of showing what's possible. The second item in
05:44our sub-menu here is going to be Gear and it will link to gear.htm and the
05:48title for this is going to be Check out our sweet gear. Then finally the third
05:57item of the sub-menu is going to be Tour. That will link to tour.htm as well.
06:02The title of that is going to Find out where will be next.
06:07So, you will notice that after a while you can really get into a rhythm of
06:10this. Well, our fourth item is going to be Contact. It will link to contact.htm
06:18and the title on that one will be Contact us. That's not our entire list. So
06:25we'll find out links here, but that's okay, because it is really easy to add
06:28new ones. So, right after Contact, I'm going to go up and click the plus button
06:31right there to add another menu item.
06:34This item is going to be Shop. It will link to shop.htm and the title for this
06:40one will be Shop Desolve. Now, that one does one have some drop-down links as
06:46well. So it is really easy to add those also. I'm just going to highlight Shop,
06:50come here and click plus for the first sub-menu Item, that's going to be
06:54Prints, and it will link to prints.htm. The title for that one is going to be
06:59See our featured prints.
07:02Then one more sub-menu Item. This is going to be Specials and this is going to
07:10be specials.htm. The title of that one, Check out this month's specials. So it
07:19just takes time. It's certainly not hard to add these items. You just have to
07:23stay focused to make sure you are placing the sub-menus items where you need
07:26them, but really it's extremely easy to do. So I'm going to go ahead and save
07:31this, I'm going to click OK. And then I'm just going to preview that in my browser.
07:37And we see our menu bar with drop- downs and everything. Except for that and
07:42there is a good reason for that, because we have an element floating on top of it.
07:45So our menu bar is now in place and populated with the links we need.
07:49But it is not however looking or even functioning the exact way we would like it to.
07:53Now we need to carefully modify the CSS controlling our menu functionality
07:58and we'll start that next.
Collapse this transcript
Styling menu bar placement
00:00Although some of our menu bar styling is being taken care of by our site's
00:04external styles, the bulk of the menu styling is being performed currently by
00:08the external SpryAssets CSS file. Currently our external style sheet is
00:12controlling the background color, foreground color, rollover color and spacing
00:17for the links. Every other property is being controlled through the default
00:21menu bar styles.
00:23Although, we certainly do need to tweak some of the visual properties of our
00:25menu bar, our most pressing concern currently with the default styling is the
00:29placement of the menu bar and the location of the sub-menus, when they are
00:32revealed. Based on what we are doing for our final design, we would like the
00:35menu bar to be at the bottom right of the header element and to prevent the
00:39sub-menus from covering up a content below it, we would like to move here above
00:42the related menu items that are below that.
00:44So to do that, we'll need to adjust some of the layout properties in the
00:48default style sheet. I'm once again, going to minimize my panel, it's going to
00:53collapse those down to icons to get myself a little bit more screen real
00:56estate, and when I do that, I can even move my style rendering toolbar right
01:00back up there which is where I would like to have that and I'll go into
01:04Split-Screen View, so that I can see design on one side, code on the other.
01:07And you will notice that in your related files right here we have our
01:10SpryMenuBarHorizontal.css. So I'll click on that. Now if you were to do a
01:15vertical menu bar, that would be SpryMenuBarVertical.css. As I mentioned
01:19earlier, as we were reviewing our menu bar structure, you really want to read
01:23the comments of these styles very, very carefully because making a wrong change
01:28can cause your menu bar to be placed in entirely area, the drop-down menus
01:32might really looking weird or they may not even work altogether.
01:35So our first number one priority is to go ahead and move our menu bar into our
01:39desired position. So what I'm going to do is find this rule right here,
01:43ul.MenuBarHorizontal. That is the parent menu bar element and that's what we
01:48are going to use to control the positioning. So I'm going to change this, so
01:53that it does have a position attribute and I'm going to use absolute positioning.
01:56Now it's inside the header element. This is a really important point,
01:59the header element has a relative positioning attribute. So anything that we do
02:04here with absolute positioning for our menu bar is going to move it around
02:08inside the header bar, so it will move it relative to the top left-hand corner
02:12of the header element and it's exactly what we want. So we have it position:
02:16absolute, and what we'll do here is we'll do a right of zero pixels and we'll
02:22do a bottom of zero pixels.
02:25So that's going to move the right bottom edge of our menu bar to the right
02:30bottom edge of our header and if I save this file, click over here in Design
02:34View, you can see that our menu moves right down in the place, so that it's
02:38perfect. So far so good. Now one of the things I noticed is the menu bar items
02:44are a little too wide. There is a little bit of a problem here altogether
02:47actually, when I do a horizontal menu, I really like to have the width of the
02:51element sort of take care of itself and that's once place where me and
02:55standards compliance typically take a little bit of a side journey, because if
02:59you float elements by and large you are supposed define a width for it, but I
03:02founded there is still the cross browser compliant to get away from that every
03:05now and then.
03:06Well, not so much with this menu bar. If you don't specify width of the list
03:09items that you are going to float, then portions of the menu bar may not work
03:12inside the browser. So you want to really be careful about that. So, I'm going
03:15to scroll down in my styles a little bit and I can see that for my
03:19ul.MenuBarHorizontal li, so those are the individual items within the menu
03:23itself, that they are given a default width of 8 ems. That's a little high, I'm
03:28going to change that to 6 ems and save it and I'll click over here and you can
03:33see now they are a lot shorter.
03:35That, only takes a little bit or trial and error to be honest with you. We are
03:38going to leave enough space for the little arrows when they are necessary and
03:41you want to leave enough space for your widest element. Now the next thing we
03:44are going to do is we are going to go down and find our ul.MenuBarHorizontal
03:48ul. So this is dealing with any of the unordered list nested inside of the
03:55apparent unordered list and that would be any of our sub-menus.
03:58So we are going to go ahead and affect our sub-menus as well. It is 8.2 ems
04:03wide, we are going to change that to 8. So once again we are just sort of
04:05shrinking down the width of the sub- menus. Now, right now I'm not terribly
04:10happy with the way that the sub- menus are functioning, because they are
04:12dropping down instead of dropping up. So we need to go ahead and take care that
04:16next as well. And you will notice that we have this rule, ul.MenuBarHorizontal
04:23ul.MenuBarSubmenuVisible.
04:26So again, this is a dynamic class that's being assigned when a sub-menu is
04:31visible and that's going to be visible when a user rolls over the parent link
04:34and it shows up. So right now, the left position is auto, meaning that it's
04:38going to align its left edge with the left edge of its parent element. We are
04:41going to change that a little bit, but not going to affect the left edge just
04:45yet. But we are going to go down and type in bottom and we are going to give it
04:53a bottom value of 1.6 ems.
04:57Now if you are wondering, how in the world is that even working? Well notice
05:01that the ul.MenuBarHorizontal ul is giving it a position at absolute. So it's
05:06inheriting a positioning attribute, we don't have to explicitly give it one and
05:09we are giving it at a bottom value there to also move it up a little bit. Now
05:13remember negative values would move me down, positive values would move me up.
05:17And then one last thing here, we are going to go into the actual items within
05:21the sub-menu and we are going to shrink them down in size as well to match
05:24their parents. So instead of 8.2 we are doing 8. So you should always double
05:28check if you change one value, sometimes you got to go elsewhere and change
05:32that value again. So I'm going to go ahead and save that file. I'm going to
05:36preview that in my browser and now if I rollover my elements, so my menu is in
05:42place and my drop-downs or no one are dropping down, they are dropping up.
05:47So it doesn't look exactly the way we want it to, but it is positioned and
05:51functioning that we needed to. So our next step is going to be the modify the
05:55styling of our menu which we'll require as not only to make some additional
05:58modifications to the default styles but to add some additional styles as well.
Collapse this transcript
Styling menu bar links
00:00It's time to finish up our menu bar styling by taking care of the remaining
00:03link styling. We need to make sure that the users have the visual clue that a
00:08link contains a sub-menu, we need to style our sub-menu links, so they are
00:12visually distinct and we want to add a bit of flare to our sub-menus by giving
00:16them a graphical treatment that separates them visually from our main menu.
00:21We are going to do this all in Code View because sometimes when you are
00:24manipulating your CSS, it's a lot easier to do it in Code. So, I'm going to
00:28click on the SpryMenuBarHorizontal.css right here in my related documents and
00:32then I'm going to switch to Code View.
00:34Now one thing I want to point out about these default styles, it's not true for
00:37every widget, certainly for the menu bar one. Notice that we have different
00:41sections and they are commented. So this is layout information. If we scroll
00:44down a little bit and here we have our design information. Now you want to be
00:48really careful here, because notice that the design information has a
00:52ul.MenuBarHorizontal ul and layout has a ul and in fact we'll find it, here we
00:57go, ul.MenuBarHorizontal ul.
01:00So you have to really make sure you are modifying the one that you think you
01:04are going to modify. The other thing that we are going to do here is, we are
01:07going to add some new rules ourselves. So I want to keep the comment
01:10inconsistent so I'm going to highlight one of the commentated regions. One of
01:14those little comments here and just copy that, so that it want me add our own
01:17code, I can add my own little commenting.
01:19So I'm going to scroll down and just in front of the Submenu Indication, right
01:24on the line 114 or so, I'm going to create some blank space, paste this comment
01:28again and here I'm going to replace Design Information with Added By Author and
01:36then I'm going to highlight little comment out beside that and type in styling
01:41submenus. Again that's little note to myself that I added these styles and the
01:47reason as to why I added these styles.
01:49Trust me, you may not see the use for that if you haven't done a lot of CSS
01:53work, but after a while it's really nice to go back into your own code and read
01:57notes that you made to yourself, so that's very handy. So the first one we are
02:01going to do here, is we are going to type in #header. So you can see that I'm
02:05making these rules more specific right off the bat, so that I'm overwriting
02:08what's happening with the default styling of my site.
02:12So I'm going to type in #header ul ul. So remember those are our submenus. Then
02:16I'm going to do space li a:link, so I'm going to be using the pseudo selector
02:22link there. I'm going to type in a comma and then I'm going to do another one.
02:26I'll group another selector here, so #header ul ul li a:visited.
02:33Now we certainly could have taken advantage of some of the dynamic classes that
02:37are assigned. There is a hover class for example that is assigned dynamically.
02:42I like doing it this way however because this way, I'm not really relying in
02:46the JavaScript. If the JavaScript is turned off, the roller rule still work in
02:49the submenus will be visible because they are just nested lists.
02:52So that's actually kind of a nice thing. So I'll go down to the next line here
02:55and we are going to give them a background color of white. So they are going to
02:58be a little different than our main links. I'm going to go ahead and give them
03:02a margin-right of zero and that counters the existing margin that is set on the
03:09parent ones spacing them apart, these are going to be vertically stacked, so
03:11they don't need that. Then I'm going to type in color and their color is going
03:17to be #58725A.
03:18Font-Size is going to be 0.8 ems, so we are going to make them pretty small and
03:27then we'll give little bit of padding. Padding top to bottom is going to 0.4
03:31ems and then a space and padding left to right is going to 1 em that person is
03:35going to give us a little bit of space between the background color and the
03:37text itself. So that will be that rule.
03:40Lets go down to our next one and here we are going to type in #header ul ul li
03:48a:hover. So we are going to go ahead and deal with the hover of our submenu
03:52links. Here we are going to change the color to #fff and we are going to go
03:56ahead and give it a background of #88A48A. So, just sort of inversing that a
04:07little bit. So I'll go ahead and save that and then I'm also going to do
04:10another little comment here.
04:11I am going to do /* to open up the comment and then I'm going to type in end
04:16author styles and I'm just going to go ahead and get myself a few more stars
04:22out here, let me know that that section has ended there as well. Now we are not
04:27quite done yet however, we are going to go down and modify some of these
04:29existing styles a little bit more so I'm going to go down into my submenu
04:33indications styles and here I'm going to modify some of my background graphics.
04:39So what we are going to do is we really only want our arrow to show up to
04:43indicate that there is a submenu, I really don't care about having it show up
04:46as the menus split up, because I have got little other background graphic that
04:49I'm going to use this as a separator and as it hovers over, I don't really need it either.
04:53So what I'm going to do is I'm going to take each one of these except for the
04:55first rule, which is ul. MenuBarHorizontal a.MenuBarItemSubmenu. So always
05:01except the first rule, I'm going to take everything except for background-image
05:04and I'll replace background-image with none. So the bottom three rules there,
05:09go ahead and replace background image with none and then it will just turn the
05:12background of the image off for that particular item.
05:14So in that case no harm, no foul. Now I'm going to scroll back up. I'm going to
05:20go outside of my author styles and into these design information styles and
05:25around line 92 or so, right around here find the ul.MenuBarHorizontal ul. I'm
05:33going to change the border to a background graphic. So I'm going to highlight
05:37that and I'm going to totally replace the border, so highlight entire border
05:40and type in background and then : space and the what we are going to do here is
05:45we are going to do a URL.
05:46Now, once again you can just type it in, if you would like, hit Return and that
05:49way you can browse. Now in this case we are going to go to the Chapter_03,
05:5203_04 folder and to the images directory and what we are looking for here is we
06:00are looking for the submenu_back. So you may have to scroll a little bit.
06:06submenu_back, I guess I could have typed in the S. There it is and you can see
06:13it's a transparent GIF file and it has the little bracket indicator to it. So
06:17I'm going to go ahead and click OK on that.
06:19Now that's going to be no-repeat. So, we really want one of those and we are
06:23going to have to replace it by typing in center and then bottom. So what that's
06:27going to do is it will place it against the bottom of the element and it will
06:30center it horizontally, so that's perfect. It's exactly how we want that. Lets
06:34go ahead and save that and then lets finish up by going up and taking a look at
06:40our submenu visible.
06:41So I'm going to scroll up to right around line 58, 59, right here. This is the
06:47row we want, ul.MenuBarHorizontal ul. MenuBarSubmenuVisible. So this is the rule
06:54that effects the nested on our list as a submenu is visible. We have got that
06:58background graphic showing up right now and when this is visible, we want to
07:02give a little bit of spacing, so that we can see that transparent background graphic.
07:06So I'm going to click underneath that. I'm going to add a little of padding to
07:09the bottom because remember, when we attached the graphic to the bottom of the
07:13element and we are going to do a padding to the bottom of 15 pixels.
07:17So if 15 pixels were the padding to the bottom that should be enough to allow us to see that graphic.
07:21So go ahead and save that, preview that in your browser and well, everything
07:27looks okay for the most part. We notice that our submenu items are coming up,
07:31the background graphic that we ask for here, the transparent one is showing up
07:34and working just fine. Padding is giving us enough spacing, so we can see that
07:38but there is one problem. Our background graphic, our images, those little
07:41arrows that we were hoping for are not there.
07:44So I'm going to close this and I'll go back into CSS and if you scroll down to
07:49that line 142, this is the rule that should be showing us that but it's not. I
07:55notice that the URL for the graphic is SpryMenyBarDown.gif. If I go over and
08:00look at my SpryAssets, I'm going to clean this up little bit. There it is.
08:03SpryMenuBarDown.Gif, So it wasn't showing up.
08:05Well, see this is going to be a recurring problem if you are modifying your
08:11Spry widgets, you are constantly going to have to battle between the existing
08:15styling that you have in your site versus the styling that you do for your
08:18widget. To be honest with you, if you are doing a workflow where you are adding
08:21your widgets as you are designing your site, this is little easier to deal with
08:24because you're not having to constantly go back and overwrite some stuff.
08:27In this case, it's just not a specific enough rule. So if I go back to my code
08:32and I click on line number 42, I can just add #header in front of all that to
08:37make the rule a tad bit more specific and that is going to deal with the fact
08:41that one of those rules had told the background to be none. So, now if I
08:45preview that in my browser again, there we go. Now one thing I do want to point
08:49out, you see how the arrows are pointing out, that is not the default graphic.
08:53We went and took that into Photoshop or Fireworks or whatever image editor y
08:57have and I just rotate the triangle, so it pointed up, pointing in the
09:01direction that our menus are going to be going, perfect. The good news is, our
09:06menu bar looks and functions exactly the way that we want it to. So what's the
09:11bad news? Well, so far we have absolutely no plan for what to do if the browser
09:16doesn't have JavaScript enabled. So that's something that we are going to have
09:19to tackle next.
Collapse this transcript
Coding for non-JavaScript enabled clients
00:00The fluid and changing nature of the web means that the one constant web
00:04designers can count on is change. Truly mastering your craft means making sure
00:08your code works in older browsers and current browsers, in alternate user
00:13agents and with an eye towards future clients and standards.
00:16Now usually this means you have to do a little bit more work then you would
00:18like to make sure your site is rock solid for the majority of your clients.
00:22While initially more painful, it's one of the things that separates the great
00:26designers and sites from the merely good ones. The devil as they say is in the details.
00:31Before we leave our menu bar, we have to sweat one more detail, taking care
00:35of user agents that are not JavaScript enabled. So here I have my index.htm
00:40page open and I'm previewing in the browser, you can see our drop down menus
00:44are working just fine.
00:45But if I go up to this browser and I turn JavaScript off and reload it...
00:52Well, the rollovers are still working because they are not tied into the menu
00:55structure but you didn't have no idea that About and Shop had additional links.
01:01So at that point, you got nothing going on there so we need to make sure that
01:06we are dealing with that. Let me go ahead and turn that back on, just in case I need it later.
01:09All right, now there are multiple ways to serve our content based on whether
01:13JavaScript is enabled or not. One of the oldest and most consistent ways of
01:17doing it, is by using what we called the noScript tag. The noScript tag is
01:21ignored and thereby not rendered by any user agent that has JavaScript
01:26turned-on. For those devices that have JavaScript turned-off however, the
01:30contents of the noScript tag are rendered exactly where they are within the code.
01:35While noScript does have a few support issues such as incomplete support within
01:39the head tag, it offers a solid and widespread method for supplying alternative
01:44content to those who are not JavaScript enabled.
01:47Since, our menu bar involves navigation, we'll serve up alternate navigation to
01:51our sub-menu pages and since our site contains a lot of other Spry based
01:55content, pass along a message advising the user to enable JavaScript. So what
01:59we are going to do is for the pages that have alternate content, let me refresh
02:03my browser real quick here. So the About and Shop, these guys have drop down
02:07menus. Those pages will have a little bit of a sub-menu right above the
02:10headline. For pages like Home and Galleries and Contact, we just want to pass
02:15along a little message that says, hey, you may want to consider turning
02:18JavaScript on.
02:19Okay, and this is another thing that 's a little bit easier to do in Code view.
02:23Now if you would like, go ahead and highlight, this headline New York City
02:26because flipping back over to Code view and focusing on the Source Code, it
02:30will jump you right down where you want to be.
02:32So right there on line 70, just inside this opening div tag where the class is
02:37article, go ahead and create a little bit of space for yourself there and we
02:40are going to work right there. So the first thing I'm going to do is I'll put
02:43up a noScript and then I'll hit Return and I'll close my noScript tag.
02:48So anything that I want to be visible when JavaScript is turned-off, should go
02:53inside those tags. And inside that, I'm going to type in a paragraph tag then
02:58I'm going to go and give it a class attribute and my class is going to be
03:02noScript. We haven't written a style for yet, but we'll and that will allow us
03:06to style our new script paragraph text, little bit differently than the rest of
03:10our text in our page.
03:11So I'm going to type in something kind of funny here. So I'll go, I'll say,
03:15'Psst. Hey. You have JavaScript turned off. If you want to see the REALLY cool
03:27stuff on the site, turn it on. Thanks!' Always pays to be nice, right.
03:35All right, so I'll close the paragraph tag, there we go. And I'm just going to
03:40go ahead and save that. Now still in Code view I'm going to switch over to our
03:44main CSS file, which is main_hasMenuBar .css, and I'll scroll all the way down
03:53to the bottom of my rules, right from noDisplay. And I'll just hit Return. We
03:57are going to add another class here. It will be the noDisplay but I need to
04:00make that a little bit more specific, so I'm going to type in #container
04:03#mainContent p.noScript.
04:11Since it's always going to be in the same place and since we only want to
04:14assign it to paragraphs, we can be that specific with it and make sure that
04:18it's going to render properly. This is going to be the easy one, this is going
04:21to be font-size, and the font size is going to be 0.8 ems. And then I'm going
04:28to type in color and we are going to do a color of #f00 which is red, so we
04:34want to make it really red, so it stands out.
04:37So we'll go ahead and save that file. I'm going to preview that in my browser.
04:42So currently, I don't see anything in terms of the noScript tag but if I turn
04:47my JavaScript off and refresh my browser, you will notice that navigation menu
04:54is gone again but now we have this nice little message that says, Hey. You have
04:57JavaScript turned off. If you want to see the REALLY cool stuff on the site, turn it on.
05:00So nice way of passing messages to people who don't have their JavaScript
05:04enabled. So let's turn our JavaScript back on and now we have to concern
05:09ourselves with the pages that actually have some sub-menu navigation. So I'm
05:14going to go over to our Files panel and I'm going to open up the about.htm as
05:18well. Now remember the About page, if I go and take a look in the Design view,
05:22the About menu item has three sub- menus, Contributors, Gear and Tour.
05:27If I'm on the About page and JavaScript is turned off. I would like to have a
05:30little bit of a sub-navigation just below the main navigation. No, no we are
05:34not going to do a whole lot of crazy styling with this, we are just going to
05:38place that content just about the article so that somebody could have easy access to that.
05:42Now what better place to start with content, you have already done. So I'm
05:45going to go back to the index page, I'm going to stay in Code view but I'm
05:48going to go to my Source Code. And let's scroll down to find the noScript tag
05:53that I created earlier. It was around 72. And I'm going to highlight the
05:58opening and closing noScript tag and copy that.
06:00So I'm going to go back over to the about.htm. Once again I'm going to focus on
06:04Source Code. And again if you are trying to figure out exactly where to place
06:08it, clicking inside this main heading is a good way to do that. So I'm going to
06:10do that, click on the Source Code, hit Code and it jumps me right down where I
06:15need to be. So that line 74 here, just inside the galleryArticle div, I'm going
06:19to go ahead and paste my noScript content.
06:22Now it's going to be a little different, I still want that little paragraph to
06:25come in and say, hey, you know just in case but actually above that I want to
06:29place my other menu. So I'm going to do another little paragraph, this one I'm
06:33not going to give a noScript class to because I don't want it to have that
06:36styling. And I'm going to type in Contributors and then little pipe character
06:42and I'm going to type in Gear and little pipe character and then I'm going to
06:47type in Tour and then I'll close the paragraph.
06:50Now of course, those are all links, so I'm going to highlight the word
06:53Contributors here and I'm just going to wrap this using Wrap tag right over
06:57there and I'm going to wrap this in an a tag and the href for that is going to
07:03be contributors.htm. And we can also do a title if we like, and I'll go ahead
07:10and title this, Meet our Contributors.
07:16So all the stuffs that we had in our previous link, want to go ahead and do
07:19that for all of these guys. So I'm going to highlight Gear. We'll wrap that in
07:22an A tag as well. We'll href that to gear.htm. We'll go ahead and give it a
07:30title of Check out our sweet gear. Then I'm going to run in Tour, wrap that in
07:41a tag, href is going to be tour.htm and the title for that one is going to be
07:47-- we'll do a, Check out our tour dates.
07:51So almost exactly what we had earlier, perfect. So I'm going to go ahead and
07:54save that. Now that we have this, I'm also going to open up Contributors. So we
07:58are not going to do all of these but we are going to get a good feel for how we
08:01would implement it in one page versus another.
08:04So I'm going to highlight everything in the noScript tag and copy this. I'll
08:08open up Contributors and I'm going to do the same thing. I'll just go into Code
08:13view. Highlight that one so I know where to place the noScript tag. And right
08:17there on line 72, I'm just going to drop it in there. Since this is
08:20Contributors, I want to let people know that they are on the Contributors page.
08:23So I'm just going to go in here and I'm going to strip out that a tag, so there
08:28is no link whatsoever there. And that way it will give the appearance of yes we
08:32are on the Contributors page and we don't need any link. So I'm going to go
08:34ahead and save that.
08:36And starting with the index file, I'm going to preview this in my browser. Now
08:42we already know how it works with JavaScript turned-on, so I'm going to come in
08:46and turn JavaScript off, refresh our page. So now if we click on the About
08:51page, not only do they get the message, they get the links to the sub-pages
08:56there as well. And then if I click on Contributors, I still get the message and
08:59it lets them know they are on the Contributors page and the sub-links to Gear
09:03and Tour. So I'll just repeat that process for both the Gear and the Tour. I
09:07would also repeat it for the sub-menu pages underneath Shop, which would be perfect.
09:12And that is certainly not the most robust alternate content method that's ever
09:15been served up but we are providing alternate means of navigation for those
09:19without JavaScript and a gentle reminder that the page experience would be
09:23improved by enabling JavaScript. We now have a properly styled, functioning
09:27cross browser compliant drop down menu that also serves up alternate content
09:32for non-JavaScript clients.
09:34All right. While we did have to do some tweaking to get exactly what we wanted,
09:38it is worth noting that taking advantage of Dreamweaver and using the Spry
09:41widget saved us some serious time and gave us a head start on both
09:45functionality and styling.
Collapse this transcript
4. Validating Form Data with Spry
Exploring form validation
00:00I have been putting it off but I really need to start a Twitter account.
00:03Yeah, I know. All the cool kids are doing it but I have barely time to return
00:07emails, much less let everybody know what I'm doing every second in a day.
00:10Still, here we are at Twitter's signup page and this is actually a really good place
00:15to start talking about form validation which is what Chapter 4 is all about.
00:20So let me click inside the form, just start typing, and hey, look at that. As soon as I
00:25click in this and enter your first name and last name, okay fair enough.
00:28So this form is helping me. I like to be helped. Pick a unique name on Twitter.
00:33How about James? It's going to check. You'll notice it goes" oh, user name has already
00:36have been taken." Deadgumit. All right, how about DreamweaverJames?
00:44Uhoh. How about DreamweaverJam? Since James isn't going to fit. I'm checking, well,
00:49believe it or not- I know it's hard to believe it- it's not taken.
00:52So now I'm going to do a password and oops, '6 characters or more be tricky.'
00:57Tricky is six characters so let's do tricky.
01:02Too short? Weak? Oh, come on, man, what's up with the Weak stuff?
01:05Well, hey, did you notice how all this stuff
01:07is happening as I'm filling out my form? I'm not having to actually
01:10submit the form in order to get this kind of feedback that's going to help me filling out.
01:14Now this may seem like a really obvious solution like duh, why wouldn't you want this?
01:17But client-side form validation has only recently hit its stride.
01:22So validating form data is just another way of saying that you are checking how
01:26the user is filling out your form. By validating forms, you can prevent a form
01:30from submitting incorrectly or simply make sure that you are getting the
01:33required information from the user. There are two ways that you can validate forms:
01:37you can do client-side and server-side validation.
01:42Server-side validation requires the use of server-side software, such as Cold
01:45Fusion, PHP or .Net. It's usually done by having the server check the form
01:50data as it's being submitted, return an error if the form data doesn't validate
01:54and then display a message to the user detailing the problems.
01:57Well server-side validation can be extremely robust, it does require a server
02:02request in order to check for errors. Because of this, the feedback to the user
02:07isn't received until the form is submitted and for many users this can be a
02:10little frustrating and off-putting. Well, that's where client-side validation comes in.
02:14Client-side validation is typically handled by JavaScript and can check form
02:17data as it's being filled out. When the user moves from one form of element to
02:21another and when the form is submitted. Now this allows you to give the user
02:25immediate feedback and better overall user experience. The only drawback to using
02:29client-side validation is the JavaScript has to be enabled in the browser in
02:33order for it to work. It's not a bad practice to have at least some simple
02:37server-side validation to handle non-JavaScript enabled clients.
02:40So in this chapter, we are going toe examine doing client-side validation using
02:44Spry includes multiple form validation widgets that check items such as
02:48text fields, passwords, checkboxes, radio buttons and more. Their simple
02:52structure and clear CSS makes creating and styling user feedback a breeze as well.
Collapse this transcript
Inserting text field validation widgets
00:00So our desolve.org site does a registration form and I'm previewing this now in
00:05the browser. This is just the default form and notice that if I click, I do get
00:11some feedback in terms of at least letting me know where my focus is, but
00:15that's really being handled right now by CSS anyway.
00:18So everything else seems to be working okay, but I'm not getting any user
00:22feedback. I have no idea whether it's a good password or not. To be honest with you,
00:25I don't even know what I typed. And there is nothing here outside of some cool CSS work.
00:32There is really nothing there to help me fill out this form.
00:34So we need to take this form and upgrade it using some of our Spry validation
00:38widgets. So our first step in adding client side validation to our forms will be
00:43to replace some of the existing form elements in our registration form with
00:46Spry validation form widgets.
00:48We'll first replace the Email and Password text fields, since both of them
00:52include information that is required for people to register with our site.
00:56As we add the widgets to our page, we'll also set options for each widget that
00:59will control which message is displayed if the data is not valid and choose
01:04exactly when to have Spry validate the data. So there is a lot of options available to us here.
01:08So I'll go back in the Dreamweaver. Now for those of you who are kind of new to
01:11the party here and they are following along with me, we need to go ahead and
01:14set a default directory for our Spry Assets. So the Dreamweaver is adding those
01:18to the right folders.
01:19So I'm going to go in the 04_01 folder. I'm going to right-click choose New
01:24Folder. We are going to call this SpryAssets. Again that just keeps it
01:27consistent with what Dreamweaver normally uses, although you could name this
01:31anything that you want.
01:32Next thing we have to do is go up to our Files panel, go up to the name of your
01:36site and double-click that. That will open up our Site Definition dialog box
01:41and in the Events tab we want to go in the Spry category and here we'll browse
01:46and we'll go into Chapter_04 > 04_01 > SpryAssets. Select or Choose on
01:54the Mac and then click OK and we are ready and raring to go.
01:59So I'm going to scroll down and find my existing email element within the form.
02:04We are going to replace this with the Spry validation widget. Now the
02:07interesting thing here guys if you are hand coding this, you really wouldn't
02:10have to delete anything, but because we are not hand coding it and we want to
02:14go through the automated process of having Dreamweaver insert this, I'm going
02:17to go ahead and select both the Label and the Form Element and I'm going to delete them.
02:22I want to make sure I don't get rid of the paragraph that's there but I need
02:25the label tag gone and I need the input tag gone. So if you are not entirely
02:29comfortable with what's going to on here, you might want to do that in a Code view.
02:32So if we go up to our Insert toolbar and find our Spry panel, we can see that
02:37we have all of these Spry validation widgets. You don't always have to go Spry
02:41to find that; you can click on the Forms>Insert toolbar as well and they are
02:45all right there. So you can insert these as you are building out, your forms
02:49that as well they are the same exact items.
02:51So I'm going to go ahead do a Spry validation text field. Now the interesting
02:54thing here is if you ever built a form in Dreamweaver, this is instantly
02:58recognizable. You've done this before. So we are going to go ahead and give
03:02this an ID, which is Email for this particular form element. The label is going
03:07to say Email:.
03:10Now for those of you that aren't familiar with forms, the ID is the name of the
03:13element itself. The label is the text that's going to show up beside that we
03:16are going to attach the label using a for attribute and we have our form
03:20elements tabbed index, so the tab index of that element will be 20.
03:24We'll go ahead and click OK. Now that had nothing to do with form validation.
03:28That had everything to do with making sure that the form element meets
03:32accessibility standards and that's something that is a preference that you can
03:36turn on or off inside Dreamweaver.
03:37I am going to go ahead and select form element itself and using Properties
03:42Inspector I'm going to grab the Class pulldown menu and choose Text. We are
03:46good bid in inserting this form validation widget and we haven't seen really
03:49anything to do with Spry so far at all. Well, here is one thing different.
03:54Notice that when we clicked on the text field, around it we have this little
03:58blue Spry tab that says Spry text field.
04:01If I click on that tab, now the Properties Inspector is reflecting all of those
04:05Spry validation properties. So this is a Spry text field. So what we are going
04:10to do is we are going to grab the Type pulldown menu and notice that you
04:14validate against certain required items. Such as a Credit Card number or a
04:18Date, and in our case we want an Email Address. So I'm going to validate that
04:22versus an Email Address.
04:24So the JavaScript will make sure that whatever somebody enters here is at least
04:27an email address in the terms of the @ symbol and the .com, or .org or whatever it may be.
04:33Now I can also validate this and notice that by default when the form is
04:37submitted, Spry is going to validate this form. But I can also validate it on
04:40blur which means when somebody leaves focus or on change as somebody is typing
04:45that in, I only want to validate that on blur and submit, because as they are
04:49typing in, I don't want to say, hey, make sure you type in an email address.
04:52But you can do that if you wanted to.
04:54The next thing that happens is here we have a Preview state. If I grab that
04:58pulldown menu, this is what the form element looks like initially when somebody
05:01first loads the site up. Next, we have the required format, and you can see it
05:06changes color. It has a red background color and now it says a value is
05:10required right out there to the side.
05:12In the Invalid Format we could say Invalid format. Now we want to make that a
05:16little bit specific. So what I'm going to do is I'm going to go up to the
05:19Required and I'm going to highlight the text right here that says a value is
05:23required. You will notice that I didn't highlight the period. There is a little
05:26bit of bug inside Dreamweaver here and if you highlight the whole text, sometimes
05:29it doesn't allow you to actually change it. You have to go in Code view and do it.
05:32So if you are going to stick with working in Design view, my advice is do not
05:36select the whole thing. All right, I'm going to type in Valid email please and
05:43if you want, you can replace the period with an exclamation point, if you are
05:46really, really serious about it.
05:47Now I'm going to go ahead and do the same thing for the Invalid Format. I'm
05:51going to let him know what that format should be. I'm just going to type in
05:55Valid email please. Now how in the world is all that structured? Well, if I
06:01highlight this and switch over to Code view, you can see that these messages
06:05are really just inside of span tag and the span tag will display dynamically
06:10based upon whether the form element is whether or not.
06:13So I'm going to go ahead and save this and I'll notice that it's going to copy
06:16over the SpryAssets folder that we set as the default folder.
06:19SpryValidationTextField.css and the SpryValidationTextField.js, so both the
06:24JavaScript and Cascading Style Sheets being able to work. So I'm going to do a
06:28Save All and preview that in my browser.
06:32So now when I click inside our email, I don't really get anything, but then
06:36when I start typing, I don't get anything. But let's say I don't feel like
06:40typing in a full email address and I hit tab. It tells me, hey, you need a
06:43Valid email please. And if I just typed it then correctly, and the tab it goes away.
06:52Same is true for submitting the form. If I go down and submit it, it
06:58immediately gives me that same user feedback that I need a valid email. So now
07:01we are getting somewhere. It would be pretty counterproductive to have somebody
07:05register for our site without knowing our email address. So now that we have
07:08our validation widget in there we're ensuring that they are at least typing in
07:11an email address whether it's valid or not.
07:14So we are not quite done yet. So next we'll deal with validating our password
07:18text field and adding a confirmation widget as well.
Collapse this transcript
Inserting password and confirmation validation widgets
00:00Since our form is allowing our users to register for our site, we want them to
00:03choose a password to make sure they are choosing at least a little secure
00:08we'll restrict their passwords to at least eight characters.
00:11Remember that if you are using a password text field, users wouldn't be able to
00:14see the characters they are typing in and to make sure they don't make a typo,
00:18we want to make them type it twice. Well, thanks to our Spry validation
00:21widgets, we can do just that.
00:23So here I have the contact.htm opened from the 04_02 folder and before we get
00:29too far into this, let's go ahead and reset Dreamweaver's default SpryAssets
00:33directory. So I'm going to go over to our Files panel, find the name of my site
00:36and double-click that. That will open up my Site Definition dialog box and I'll
00:42click on the Spry category and just for my SpryAssets directory I'm going to
00:47browse for the Chapter_04>04_02> SpryAssets folder and you can either hit select
00:53of choose based upon your operating system.
00:55So I'm going to take the existing password text field and it's labeled and I'll
00:59delete that, but leave the empty paragraph and then I'm going to go up to my
01:03either Forms object or Spry Insert toolbar. And I'm going to find the Spry
01:07validation password widget. Let's go ahead and insert that.
01:11So we'll follow the normal procedure for inserting a text field and I'll just
01:15type in pwd for ID and password for the label, so those of were what our
01:20previous password text field had. We'll attach label using the for attribute
01:24and the tab index will be 30. Let's go ahead and click OK and then I'm going to
01:29select the text field itself and using the Properties Inspector I'm going to
01:33apply the class text, so that it has the same width as everybody else, and it's
01:37being driven CSS.
01:38Now you may have noticed this little error up here. It's not really an error.
01:42Let me show you what's happening. If I go over in Code view and scroll all the
01:46way down to the bottom, you can see it's added another constructor function;
01:49this one for the validation password widget inside of our JavaScript.
01:52Now for some reason any time you add a new constructor function there
01:56automatically, it returns an error in the syntax, although it's not really
01:59there. If you just make some minor edit to it, like adding a space and then
02:02taking the space right away again, and it just goes away. So it's just a little
02:06bug there and don't worry about it.
02:08So I'm going to go back to the Design view, scroll back up, and I'm going to
02:12click on the tab for this Spry password. That's going to give me all my options
02:15for the Spry validation password widget. I can see that I have got minimum
02:20characters and maximum characters. So I can set a range for my passwords and I
02:23can even go in the More Detail and set minimum and maximum numbers of letters,
02:28numbers, uppercase and even special characters.
02:30But we'll keep it fairly simply. We are going to do a minimum characters of
02:33eight. So it has to have at least eight characters. As soon as I choose that my
02:38Preview states populates. So you don't want to see your Preview states until
02:42you've set the range of characters. That way you make sure that it has been
02:45populated with all of the different possible Preview states.
02:49So first I'm going to go to Required and I'm going to highlight error message,
02:52a value is required and I'm going to change that to Eight characters please.
03:00Clicking on the blue tab again, I'm going to switch my Preview states to
03:02minimum numbers of characters not met and keeping with character of the site
03:06I'm just going to type not yet ... and there we go.
03:10Now I also want to validate this on both blur and change as well as submit.
03:18That way if somebody navigates off of it by tabbing off of it without the
03:21requirements being met or validate and as they are typing it in, it will give
03:25them some feedback as to whether they have made the password strength-y yet or
03:28not. Perfect.
03:29I will set the Preview state back initial and now we are ready to go ahead and
03:33insert the confirmation widget. So I'll create a new blank paragraph there. I
03:37go up to my Insert toolbar and I'm going to find the Spry Validation Confirm
03:41widget. So I'm going to go right there. I click that. For this ID I'll type in
03:46confirm and for label I'm going to type in confirm password.
03:51Now we didn't have this form element before, so we are going to reap the
03:54benefits here of using a factor of ten and the tab index, because now I can
03:58type in 35 and that will snuggly put it in between of the previous two values
04:04there without our tab index. So we'll click OK.
04:06I am going to do the same thing here again guys. So I'm going to click that,
04:10give the class of text, and I'm just going to ignore this little error message
04:14until we are all done. So I'm going to click on the tab to go into my
04:18confirmation widget. Now this one doesn't have any options. You can see that
04:21what we are looking for here is which form field is it validating against.
04:26Now by default if there is a password text field already in your form it
04:30automatically chooses that, but if for whatever you were doing this to out of
04:34order you could simply grab the pulldown menu and choose the proper one, but we
04:37are going to leave the password selected, so I could, because that's the one we want.
04:40Now we have to set some values for this one as well. So I go to Required and
04:45I'm going to go ahead and highlight and I'm going to type in Values must match
04:52and I'll click on that and switch to the Invalid. So here if it validates and
04:56it doesn't match, it's going to type in Umm... that's not right ... so a little
05:03tongue-in-cheek there.
05:03All right, we are going to save all of this and when we do that, notice that it
05:08is now copying over four Asset files to CSS for both the confirmation and the
05:12password widget and two JavaScript files for the confirmation and the password
05:16widget. So I'm going to click OK, and I'm going to switch over to Code view and
05:20just get rid of little error message real quick. Again, you can just take a
05:24space or add a space and it will just go away.
05:27So we'll save that, and I'm going to take care of one more think that I forgot
05:30about. I'm going to scroll back up and choose the confirmation password widget
05:35again. Notice that right now we only have it validating on submit. We wanted to
05:38validate it when somebody changes focus and when somebody changes the values
05:42that are getting constant feedback on that. So you always want to double -check
05:45that before you save it and preview it.
05:48Let's do that. Let's go ahead and save it and preview it. Now if I type in my
05:52password, you can see it's giving me feedback and when the minimum number of
05:57characters are met, the message goes away. And before I want to confirm it,
06:00notice that again it's giving me feedback that's it's not right until it is
06:03right and then it goes ahead and confirms.
06:05Now they are working properly for the most part, but you may have noticed that
06:09the default behavior for a password does not inform the user that the parameter
06:13is the password when I establish focus on it. So I don't really get that it
06:17needs eight characters until I try to submit it with nothing in it, and that's
06:20not really what I want.
06:22Now this is kind of unfortunate. It forces us to either inform the user in none
06:25another way like just writing some default text there, it just makes them
06:29guess, frankly. So we don't have an automated way of dealing with this. It does
06:32give us a chance to discuss the rather unique relationship that styles and
06:36functionality enjoy within validation widgets.
06:38So we are going to get to that shortly and we are going to correct that to use
06:41it in CSS. Before that however we are going to finish inserting our validation
06:45widgets by using a checkbox validation widget next.
Collapse this transcript
Inserting a checkbox validation widget
00:00Text fields are not the only thing that Spry widgets can validate. In fact,
00:04there aren't many form fields that it can't. Validating anything like checkboxes
00:07and radio buttons are just as easy but since they have their own specific
00:11characteristics, it's well worth examining their settings.
00:14In our current form, there is no acceptance of our site terms and conditions,
00:18something that's pretty important for any site that offers any type of
00:21membership. So we'll insert a check box that allows people to accept our terms
00:25and use a validation widget to ensure that they have checked the box prior to registering.
00:29Now before we insert that, I'm going to go ahead and reset our default Spry
00:33Assets directory. So I'm going to go over to our site name, right up here in
00:37the Files panel, double click that. When the Site Definition dialog box comes
00:41up, I'll choose Spry and I'm just going to browse.
00:44This time we are going to go into the 04 _03 SpryAssets folder, open that up and
00:50either select or choose that. So I just want to make sure that it's going to
00:53copy over those assets in the proper folder. So I'm going to scroll down the
00:58very bottom of the form and just above the Submit button, I'd like to place an
01:02acceptance check box, so that people can accept the site's terms and conditions.
01:05So I'm going to go ahead and create a new paragraph just above the Submit
01:09button and if I go to my form objects, one of my Spry Insert toolbar, I can
01:13find a Spry Validation Checkbox. So I'm going to go ahead and click that. The
01:18ID for this one is going to be Terms and the Label for this is going to read I
01:23agree to Dissolve.org's terms and conditions.
01:31Now, we are going to Tab Index this on at 150 and we are going to position it
01:36after the form item. Did you notice how Dreamweaver did that automatically,
01:39it's very smart like that. Let's go ahead and click OK and right there is our
01:43checkbox but notice that again we get that little Spry indication around that,
01:47so I'm going to click on that tab and you can see that this is Required.
01:51You can Enforce a range and if you have a group of checkboxes together for
01:54example if there are multiple selections that they can make, you could say
01:57something like choose at least two and you could enforce that range. So I'm
02:01going to go in and go to the Required Preview state. That's really the only
02:05other Preview state that you have and here it says Please make a selection.
02:09Well, there is no rule about what you can and can't have in these error
02:13messages. So I'm going to highlight this and we are going to include a little
02:16bit more than we normally would. I'm going to type in You must approve our
02:22terms and conditions, to review them please visit our terms page.
02:34Now I'm going to hide the word Terms and using the Properties Inspector, I'm
02:39just going to link that to terms.htm. So absolutely, they can have a link
02:46inside of them. They can have link inside them, they can have images inside
02:47them, background graphics whatever you want these guys to have. It's just a
02:51Span tag and you can style the content inside of it anyway that you want which
02:54is really cool.
02:55All right, I'm going to go ahead and Save this again. It's going to copy over
02:59the Spry Assets for the validation checkbox, both the Cascading Style Sheets
03:03and the JavaScript and let's go ahead and preview that within our browser.
03:11Okay, I'm just going to scroll down and since the checkbox is really only going
03:15to validate on a blur or a change, I'm going to go to Tell me about it and
03:19notice that as soon as I typed it in without selecting the checkbox, up comes
03:23the error message and it says, I must approve our terms and condition to review
03:26them, this is our terms page, and notice that, that is indeed an active link.
03:30When I check the checkbox, I'd really like that to go away and right now it's
03:34still there. So you want some acknowledgment that they have agreed to your
03:37terms. So I'm going to close this, we are going to go back into Dreamweaver,
03:41and having selected that, we are going to go ahead and validate that on a
03:45change and a blur as well. You really won't notice the blur unless they tab off
03:49of it, but the change is what's important here.
03:51So let's go ahead and Save that one more time, preview that again and this time
03:56if I submit the form, now as I check it, notice that it's going to toggle that
04:00on and off. So that's a really nice thing to do there for a checkbox validation widget.
04:05So our validation widgets are all on the page and for the most part, they are
04:08functioning exactly the way that we want them to. The default look could
04:12integrate into our site, defined a little bit more cleanly. Now, this is
04:15usually pretty easy for any type of Spry widget you will be working with since
04:18the CSS is exposed and very easy to manipulate.
04:21However, with validation widgets, modifying the CSS like this is going to
04:25present certain hurdles for us and we'll take a look at that shortly. I also
04:29want to point out that while we didn't do every single validation widget that
04:32comes with Dreamweaver, it's pretty clear to see based upon our sampling that
04:36the process of inserting and controlling these widgets, is remarkably similar
04:40across all of them.
04:42Learning how to insert control and as we are about to do style, one validation
04:46widget should make working with any other validation widget a snap.
Collapse this transcript
Controlling basic validation widget styling
00:00Almost everything in Spry is amazingly easy to update, modify or style.
00:05Notice I said almost. Spry validation widgets start off just like every other Spry
00:10element. They seem like a snap to update and style. However, most designers find
00:15out very quickly when they try to deviate too far from their default styling,
00:19that validation widgets can be very tricky to style indeed. That is due to the
00:24fact that more than perhaps any other widget, the validation widget's CSS is
00:29directly and dynamically linked with its functionally. Knowing what you can and
00:35what you can't change is crucial to making a widget style the way that you want.
00:39Before we get too far down that road however, let's examine modifying the
00:42default styling and then reviewing the functionality of our widgets to see if
00:46it's still exactly what we want or not. And before we start reviewing the
00:51styling of this, I'm just going to Preview this one more time and I want to
00:54point out something about how the widgets react to somebody is filling out the form.
00:58So if I click in our Email and I begin to fill it out, notice that I get some
01:01feedback about the fact that I need to have a valid email address. As soon as I
01:07meet the requirement, the message goes away. Same with the password, as I start
01:10to fill that out, it tells me that I haven't got the required numbers of
01:13characters yet. As soon as I do, it goes away and when I confirm it, it tells me
01:17that the values are not right until it's met and then that goes away as well.
01:21Because of the fact that we have these items validating on change, as you
01:26change the value inside the widget that is constantly updating. Well,
01:29believe it or not, that is directly tied in the CSS, so let's go and check that out.
01:33I am going to go back into Dreamweaver and again with this contact page,
01:39you can see how many external assets are required. Here we have a JavaScript file
01:43for every widget and we also have a CSS file for every widget. We have gotten
01:47so many of these that I can't even see them all anymore and I have to use this
01:50little drop-down menu to get to some of these guys.
01:53One thing that I can do is minimize my panels to icons. That helps but I still
01:58got a lot here. So one of the things you may want to consider if you have to do
02:01a lot of validation widgets, after you have done modifying things, you may want
02:05to consolidate them into a single file and then just update that link. That is
02:08something that you can do to sort of save yourself from having all of these
02:12external assets floating about all over the place.
02:15Okay, well, we are going to start with the text validation CSS file. So I find
02:19the related file, SpryValidationTextfield.css, I'm going to click on that and
02:24go into either Code view or as we are doing here Split Screen view. Now notice
02:29that we have some class files that are dynamically assigned and these class
02:33files, basically are assigned based on the current validation state, whether
02:37it's valid or invalid, whether it meets the minimum or maximum characters.
02:42So every single widget is going to have slightly different styling.
02:44But if you scroll down, one of the things that we are going to see that's
02:48consistent in all of our widgets is we are going to have a large block of
02:51styles that deal with the required states, minimum and maximum value states.
02:55Now they are all going to show you one consistent property, Display inline.
02:59Now that's going to come back and haunt us in a big way here in just a moment
03:02but let's go ahead and style these, so they look a little better.
03:06Now first off, that Display inline is causing the messages to sometimes display beside the
03:10form element, and in some cases, it looks okay, in some cases it doesn't and
03:14rather be consistent. So I'm just going to change that to Block so that
03:17they will show up on their own line.
03:19I am going to leave the color the way it is, CC3333. But we are going to add a
03:24few more items to this. So the first thing I'm going to do is go down after
03:29color and I'm going to choose background and I'm going to do #fff, so there
03:34will be a white background for our error messages and then I'm going to type in
03:38URL and open up the parenthesis and I'm going to do ../. It's relative to the
03:44CSS file here, images/sm_skull.gif, so a small skull.gif. We are going to do a
03:54no-repeat on that and then left and center. Don't forget your semicolon.
04:02Next, we'll throw in a little bit of padding and we'll do 10 pixels to the top,
04:0710 pixels to the right, 10 pixels in the bottom and 40 pixels to the left.
04:14We are going to give it a width of 200 pixels, so we are going to go ahead and
04:18give them a fixed width for the error message.
04:21Then for border, I'm going to change the existing value that we have here.
04:24I'm going to change that to border-right and I'm going to have maybe 1 pixel and solid,
04:29 but I'm going to do #666, have a little bit of a gray color there and
04:33then I'm going to do border-bottom and we'll do the same values, 1 pixel solid
04:39and then #666 for that gray and then finally we are going to do a top margin.
04:44So margin-top of 10 pixels.
04:48All right, I'm going to go ahead and Save that and I'm going to Preview that.
04:52And now when I click in my Email as I begin to validate that, you will notice
04:56that our validation message appears and it's a little bit more in line with the
05:00design of the rest of the site. So you can style in any way you want. Remember,
05:04it's just normal content so you can go ahead and style them.
05:07Now, our display block is going to cause them some problems here in just a
05:10moment, but first let's go ahead and style everybody else before we come into that.
05:13Now they're going to have exactly the same styling. So I'm going to
05:16highlight all these rules and copy them and then I'm going to go into each of
05:20the validation widgets' CSS. I'm going to go to the password one next, scroll
05:25down to find its large blocks of styles and paste them.
05:28Again you know you are in the right place when you see that display inline.
05:31I'll paste that and save it. Then I'm going to go to SpryValidConfirm.css,
05:38find its display inline properties and paste that. And then finally, the Spry
05:43Validation checkbox, find its values and paste that as well.
05:48Now I'm going to go ahead and save all of those and Preview that in my browser
05:53again. So now when I click on my Email, I get that error message and
06:00when I tab off of it, it goes away. I'm going to enter my password, the error message shows up
06:03but now I notice, it's not going away. Hit Tab and that's valid and
06:13again, I'm not getting a lot of feedback there. So that's a problem we are having.
06:16We're going to have to deal with that in just a moment.
06:17Then if I go down to the bottom, if I submit the form, you can see that again
06:23our terms conditions page comes up. So that's nice. But we still have a larger problem.
06:30Our password and confirmation password widgets are not giving us
06:35continuous feedback now. So notice that as I type, it does fine but I would
06:40never get the error message to go away after it's correct. Same thing with
06:44confirming the password.
06:45You will notice that as soon as I get it right, it doesn't let me know and that
06:49type of feedback is actually not helpful. So our error messages do look a
06:53little better and they fit with the rest of our site design, we do have this
06:56functionality issue that's going to cause us an issue here.
06:58So tackling this problem and keeping our error messages consistent with the
07:02other widgets is proving to be a little tricky. But by going into
07:05more detail about how the widgets actually work, we'll ultimately have more
07:09control over how our validation widgets look and feel.
Collapse this transcript
Understanding validation message functionality
00:00For the most part, changing the default styling of the validation message is
00:04pretty straightforward. However, the one property that most designers trip up
00:08on is the Display property.
00:10By default, all validation messages are set to display inline, which causes the
00:15messages to display on the same line as the form element itself. Seeking to
00:19either move them, or to ensure that they will display on their own line,
00:22designers will often change the display setting to block as we have done in our
00:26previous exercise.
00:27In some cases, this will not cause a problem at all; in others as we have
00:31found, it can break or damage functionality. In this movie, we'll first find
00:36out why having an inline display is so important for certain validations and
00:39areas, which will then allows to explore ways to change the display of the
00:43message while still retaining the functionality that we need.
00:47The first thing we are going to do, is we are going to take a look at the
00:49structure of the widget itself. So I'm going to scroll down, find our password
00:53validation widget selected and switch over to the source code. So here we are
00:58within the source code, and we can see that the validation widget itself is
01:02simply a span tag, and it surrounds the entire input form element label in all.
01:09Notice that it is identified by an ID sprypassword1, and then the individual
01:14messages themselves come after the input tag, and they are surrounded by span
01:19tags as well.
01:21Here we have the span and its class, it's "passwordRequiredMsg">8 characters
01:26please, and here we have another one whose class is "passwordMinCharsMsg." So
01:30we have a feeling that we know kind of what these are, and again notice that
01:33they are nested within that span tag.
01:37So we have the widget identifying, it's up to an ID tag, and then individual
01:40messages that are being identified to use of class attributes. So the way the
01:44widget works is it dynamically applies a class to the parent span tag of the
01:51widget, which would be right there, that indicates the current state of the
01:54widget. Then by combining that with these individual class attributes, it
01:59passes styling through the CSS.
02:01Let's examine the CSS rules and that I think will become a little clear. So I'm
02:05going to go my SpryValidationPassword. css and you can kind of see what I'm
02:10talking about. So, here where we've changed the display property to block, the
02:15first value that you see here is the dynamically applied class, that's going to
02:19be applied to that parent span tag.
02:21Then this is the class of the actual message itself. So based upon the current
02:27state of the widget, you are going to get different styling based on that. But
02:30in this case, they are all kind of grouped together and if we take a close look
02:34at this, we can get some idea as to what states are available to us. Here for
02:38this password widget, we have RequiredState and MinimumCharacterState and
02:42InvalidStringState. This is just a few of them.
02:44So as the Spry functions evaluate the form element, the JavaScript is going to
02:48determine which state or states are currently active, and then assign us class
02:51attributes to the widget parent tag. That in turn is going to trigger the
02:54changes, styling based on this rules.
02:56Now, in some cases, you are going to want the message to change as the user
03:00interacts with the form element, in the case where password is certainly true.
03:03Based on how the widget is structured unless display property is set to inline,
03:07your users will not receive updates and will only see the initial display of
03:12any message. So the first state that is applied you will get to see it, but
03:16then after that the block property will keep it from changing it and displaying the others.
03:21So because of this, it's really important that any message that you want to
03:24update based on user changes has the display property set to inline. Once you
03:29are on with that knowledge, several opportunities for controlling, styling, and
03:32functionality appear to you. Number one, you could break these group selectors
03:36up. So they were all individual selectors and change the styling based on that,
03:41instead of grouping them together, the way they are here within the default.
03:43The other thing that we could do is we could change the structure of the widget
03:46itself. I mean nobody says they have to be inside of a span tag, what about
03:50putting inside of a Div tag or something like that. And in the case of our own
03:53password widget, we are going to do both. So now that we have all this
03:57information, we are going to go ahead and tackle that next.
Collapse this transcript
Controlling validation message functionality
00:00It's worth taking just a moment here to pause and talk about what works and
00:03what doesn't work with our validation widgets currently. So our email
00:07validation widget, well, it's working just fine. As I type in my email address,
00:12I get that validation message and when I hit Tab, it does just fine.
00:15However, when I tab into the Password widget, I would like to give the user
00:18instructions on our site's password requirements, monitoring the strength of
00:22the password, and then have the message disappear, and currently that's not
00:26happening. As a matter of fact the only thing that happens is the message
00:29appears and then when it meets the confirmation, it just doesn't give me anything.
00:33The same thing I would like to have with the Confirm Password, as I begin
00:36typing in that, as soon as the values match, I would like it to update and let
00:41me know that, but it's not right now. So that's not happening due to the fact
00:45that the display property for both of these guys is set to Block. So resetting
00:50that to Inline is going to cause our messages to display on the same line as
00:53the form elements and that's going to ruin our styling.
00:55So it seems like we have a choice here between functionality and styling, but
00:58not really. We are going to fix this by resetting the display property to
01:02Inline, and then modifying the actual widget structure itself to ensure the
01:06things are displaying on its own line, the way that we want them to.
01:09So I'm going to get back in the Dreamweaver. Now the first thing I'm going to do is
01:13go in and modify the actual structure of this widget source code.
01:16So I'm going to click on the Spry Password widget, and I'm going to switch to
01:20my Source Code and I think I'm just going to go straight to Code View to get
01:24myself a little bit of extra room here. And around 66, 67, 65 in there, we have
01:31our Validation widget. We have changed things up a little bit here.
01:34So I'm going to make sure that this widget structure is exactly what I need. So we've
01:38got line 65, going all the way down to the closing paragraph tag in line 68. So,
01:44this is what we are going to update here.
01:45Now the first thing I'm going to do is I'm going to take the parent tag for
01:49the widget, which is currently a Span tag, and I'm going to change that to a Div tag.
01:52So I'm going to change Span tag to a Div tag and I've got to go and find
01:57the last closing tag here right before the end of the paragraph tag, and change
02:01it to closing Div tag.
02:03Now putting a Div tag inside of a paragraph is not a really good idea. So the
02:07Div tag is now going to surround the Paragraph tag. There is no rule against that.
02:11We just need our Spry widget parent tag to make sure that the widget
02:15itself is inside of it, and in this case, it certainly is. If you did like I did,
02:20and left off a little piece of that, you can be sure to put that back
02:23together. So when you are dragging code around like that, you want to be really
02:26careful. It's very easy to make a mistake and not realizing what you are doing.
02:30Now the next thing I want to do is I'm going to take the required message;
02:33this 8 characters please message. I'm not currently seeing that and remember
02:37we want that to appear by default. I'm going to grab this, the opening and the
02:41closing Span tag. I'm going to move this up a little bit and I'm going to move this
02:46just above the opening Paragraph tag.
02:49So just inside the parent tag there, place it just above the Paragraph tag. And
02:55I'm going to change it to Div tag as well. Now, a Div tag is a block level
02:58element and despite having it set to display inline by placing it above the
03:02Paragraph tag, this is still going to display on separate lines because the
03:06Paragraph tag is going to appear on its own line.
03:09Now I'm going to do something very similar for our PasswordMinChars is not met,
03:14the Span tag here. I'm going to grab it and I'm going to move it outside of
03:19the paragraph. So the proper structure here, I'm going to go through this kind
03:24of slowly, to make sure we've got this right.
03:27Our widget parent tag is now a Div tag that surrounds our entire password input
03:33text field. We then have our required message to change to a Div tag, and it
03:38sits above the Paragraph tag, and then our minimum characters message is left
03:43in the Span tag, but it is below the paragraph as well. So we are separating
03:48the actual structure of this.
03:49Now we are going to do something very similar to the Confirmation widget. So
03:53again, I'm going to change the Span tag, as the parent tag there on line 73.
03:57I'm going to change that to a Div tag. I'll move it outside of the opening
04:01Paragraph tag. I'll find its closing Span tag here on line 76, change that to
04:07closing Div tag, and once again, move it outside the paragraph, so that we have
04:10proper nesting.
04:12The next thing I want to do, is I want to go ahead and take the
04:14ConfirmRequiredMsg. I'm going to change that to a Div tag. We are going to
04:18change the closing tag as well. I'm just going to say a value is required. I'm
04:22going to take the ConfirmInvalidMsg, change it to a Div tag as well, and don't
04:28forget to change the closing tag there as well.
04:31Now, that should also be outside of the Paragraph tag. So I'm going to grab the
04:34closing paragraph tag, and move that to the very beginning of the Div tag
04:38there. So a good thing to do here guys would be go ahead and pause the movie.
04:41Review the code structure here and make sure that your code structure is
04:44matching my code structure. But I'm going to go ahead and save the file.
04:48I'm going to go ahead and preview that, and let's see how that impacted our functionality.
04:55Notice that the password, as I begin to type in, it says Not Yet and now it updates. [00:05.01.00] Very nice. The confirmation password is giving me similar
05:05functionality. The problem here however is that the styling doesn't match
05:10exactly what I would like, so what I'm going to do is close that and I'll go
05:15into my SpryVaidationPassword.css and I'm going to define a large block of code
05:21here. I'm going to change that display back to inline , and then at the very
05:25bottom of that, I'm going to go ahead and set my font-family to Georgia, Times
05:30New Roman, Times, serif .
05:32I am going to set my font size to 0. 85 em and then I'm going to change the
05:39margin-left to 1.6 em. Now, I'm going to do that on both of these guys, so I'm
05:47going to go ahead and copy those three lines of code, go into the
05:51SpryValidationConfirm.css and do the same thing, change display to inline, and
06:01add those new rules.
06:03So let's do a Save All, preview that in my browser again. I'll see if this
06:09looks a little better. I'll click into the Password and begin typing and that
06:13matches the rest of our styling, excellent. It is updating properly, as is my
06:18confirmation password.
06:19So the only thing that's still not working is if I refresh the page, when I tab
06:23or click into the Password text field, I still would really like to get the
06:26message here, that my 8 characters are required. So we are going to customize
06:30our SpryValidationPassword.css and take advantage of something that we'll
06:34notice if we go a little bit further down.
06:37Notice that one of the states that's applied to our parent Div tag now is
06:41password-focused state. It's always been there. We just haven't been doing a
06:44lot with it. So you should really examine these CSS files closely to see if
06:48there is anything in there that you can use to do something that you would
06:51really like to do, but isn't in there by default.
06:54So I'm going to add a new rule to this. I'm going to go down at the very
06:57bottom, and I'm going to type in . passwordFocusState. passwordRequiredMsg. So
07:10now, I'm using the class that's applied to the Div tag that's around the
07:14message I want it to display. Rather than having to type in a lot of
07:17properties, I'm just going to scroll up and copy what's up here, because it's
07:21pretty much exactly the same
07:23I will scroll back down and paste this. The only thing that I need to change is
07:28I'm going to change display from Inline to Block. Now it's just to ensure that
07:34it's its own block level element. So I'm going to go ahead and save that,
07:38preview that in my browser, and now when I click inside the password, I get the
07:438 characters please message and as I begin to type, it lets me know that I'm
07:47not yet there and that message because it is applied to the focus state is
07:51going to persist until focus is removed from that. So they are always going to
07:55get that particular type of feedback, sweet!
07:58Now, our messages are styled, displayed and they function the way we want them
08:02to. Making sure that your form validates properly is something that is rather
08:06easy to do with Spry that can occasionally require a good bit of extra work in
08:10digging to get your widgets exactly the way you would like them to be.
08:13To be honest, I'd love to see their structure to be a little bit more flexible
08:17and open to things like absolute positioning, or have the ability to associate
08:21any structural element with the form element to validate much the way you can
08:24with a Label tag. It would make formatting and positioning our validation
08:27messages much easier, but as it exists, we can take advantage of the widget's
08:31code structure flexibility to exert a strong amount of control over the widget itself.
Collapse this transcript
5. Working with Spry Data
What is a Spry dataset?
00:00One of the most powerful features that Spry offers is the ability to create and
00:04store data in JavaScript objects and control how that data is presented
00:07throughout your site. Much like working with a database on a server, a Spry
00:12dataset allows you to dynamically retrieve and display data on your pages.
00:16Unlike most server-side database applications however, Spry datasets allow you
00:21to pull data from any number of sources. You can almost say that Spry is data
00:25agnostic. To occur to Spry dataset you could use XHTML, XML, JSON objects or
00:32even an Excel spreadsheets to populate the dataset.
00:35Now here is how it works. First using the Spry Data JavaScript Libraries, you
00:40create a new Spry dataset by choosing a source file to pull the data from and
00:45describe how that data should be filtered and sorted.
00:48Spry will then store that information in a JavaScript Object that is formatted
00:53much like a table with rows and columns of data by default this data is cached,
00:58but you can set Spry to refresh that data from the source at predetermined
01:02intervals or based on user interactions.
01:05To display the data on a page, we'll use what we call Spry Regions. Spry
01:09Regions allow you to process and display data in almost any XHTML tag you want.
01:15Spry Regions can be used to display repeating data, apply conditional logic,
01:19filter which data is placed and determine how the data respond to user
01:23interaction or changes. Think of Spry Regions as where the processing logic of
01:29using your data is done.
01:30Now finally, inside of these Spry Regions you will use a data placeholder to
01:35describe which information from the dataset should display in each region. Spry
01:40datasets can be used to populate widgets, build tables, create interactive data
01:44displays, retrieve and display data from another site or simply pull
01:48information from one area of your site and display it in another.
01:52As with most Spry capabilities Dreamweaver does a great job of automating most
01:56of this process for you. When building Spry datasets in Dreamweaver, you have
02:00the option of using a wizard-like interface that allows you to preview your
02:03data, control how it's filter and sorted and ultimately control how the data is
02:08presented on the page.
02:10As you would, except each type of dataset has slightly different options and
02:13capabilities based on its source data type. As we go through this chapter on
02:18working with Spry data, we'll use the two most popular dataset types, XML and
02:22HTML and work with one of the not so well known types, a comma delimited file dataset.
02:29Although not integrated into the Dreamweaver interface, building datasets from
02:32a comma delimited file opens up a world of possibilities for the average web
02:36designer. We'll start it by building a simple table from the external XML file
02:41by using an XML dataset.
Collapse this transcript
Creating Spry datasets with Dreamweaver
00:00Before we get too far into discussing the specific types of datasets available
00:04to us through Spry, it's worth our time to discuss the benefits of creating
00:07those datasets in Dreamweaver. When using Dreamweaver you can build datasets
00:11two ways, you can hand code them or you can use Dreamweaver's built-in Spry
00:15Dataset Constructor Wizard to create them.
00:18Dreamweaver's Dataset Wizard is limited to XML and HTML datasets, but since
00:23those are the types you will be using most frequently, the wizard is a
00:26compelling option for creating those datasets. Dreamweaver's Dataset
00:30Constructor guides you through the process of building datasets visually.
00:35Using it, you can choose the Data Source, preview the data, choose how the data
00:39is filtered and sorted, and then choose exactly how the data should be
00:42formatted and placed on the page. With a full set of interactive layouts to
00:46choose from, now that's pretty cool.
00:47The Dataset Constructor Wizard features three screens. The first screen lets
00:52you specify the Data Source, choose the type of dataset you need, preview the
00:56data and filter which data is brought in.
00:59Next you will choose Options for the data such as, how the data should be
01:02sorted whether the data is cached or refreshed and how the information should
01:06be data typed if that is required. Now finally, you choose how the data should
01:11be inserted on the page. You can choose from preset layout such as tables,
01:15master detail regions and stacked containers.
01:18Once you choose a layout, you can also go in and customize how your data is
01:21presented in that chosen format. You can choose not insert the data at all if
01:25you would like and that's very useful, if you want to manually control when and
01:28where the data is placed on the page later.
01:31Regardless of whether you are creating and XML or HTML dataset, you will find
01:35the power, flexibility and ease of use of Dreamweaver's Spry Dataset
01:39Constructor to be a huge time saver and a powerful way of integrating Spry data
01:43in your pages, especially if you are new to using Spry.
Collapse this transcript
Creating an XML dataset
00:00The first dataset that we'll use is one of the most powerful and most commonly
00:04used types, the XML dataset. To build and work with an XML dataset, Spry uses
00:09two library files xpath.js and the SpryData.js.
00:14xpath is used to navigate through the XML file and retrieve the data while the
00:19SpryData.js file contains all the functions used in conjunction with building
00:24and manipulating Spry data. As with most Spry, if you build the datasets in
00:28Dreamweaver, it will include these files for you in your SpryAssets folder.
00:32When building an XML dataset any valid XML file can be used. Due to the
00:37widespread use of XML in the majority of today's web applications this opens a
00:42lot of doors.
00:43If you are new to working with XML files one thing that you will need to keep
00:46in mind is that if the XML file is on another domain, you will need a learn a
00:50little bit more browser security in order to use it. Other than that, all you
00:54need to know is where the XML file is located and you can get started. And
00:58before we get started we are going to go ahead and set our default Spry assets directory.
01:02So I'm going to go over to my Files panel, find the title of my site, double
01:07click that. It's going to open up our Site Definition dialog box. We are going
01:11to get down to the Spry category and browse for the Chapter_05, 05_01 folder
01:19and we are going to find the SpryAssets folder, open that up. And either hit
01:22Select or Choose and then click OK.
01:25So now we have set that to the proper directory and all those files will all be
01:29copied there by Dreamweaver automatically for us. Before we create our dataset,
01:33let's take another sneak little peek here at our XML file. So our top tag is a
01:39contributor tag and inside that we have repeating photographer tags. The
01:43photographer tag has the name of the photographer's attribute, the country they
01:47live in, the city they live in, and then the camera that they use. So that's
01:51the information we can pull and use to display on our page.
01:55So I'm going to open up the contributors.htm and I'm going to browse down to
01:59the very bottom of the page and there is an empty paragraph down there. And
02:02this is where we'll insert a table built from that XML data. Go to my Insert
02:07toolbar and go to my Spry objects and the very first object there is the Create
02:12Spry Data Set. I'm going to go ahead and click that.
02:14Now this brings up our Spry Data Set constructor wizard and the first thing it
02:18wants to know is what type of dataset are we going to create. Now we are going
02:21to do an XML dataset and we are going to go name this dsContributors. You
02:24definitely want to name your dataset something that makes sense and references
02:31the content inside of it, instead of just ds1, ds2, ds3. Because we have
02:35multiple datasets, it's really hard to remember what's in one versus the other.
02:38Next thing we are going to do is we are going to browse to find that file. So
02:41I'm going to hit Browse and I want to go into the 05_01, _xml folder and I'm
02:48going to find the contributors.xml file. I'm going to click OK. Dreamweaver is
02:53going to go out, parse the document and then show this little schema right here
02:57of our XML file. It wants to know what I consider the root node of our data
03:01source to be and in this case the repeating node is photographer, so I'm going
03:05to go ahead and choose that. When I do that, down below that I can actually see
03:09the data being previewed. You see the country on one side, then the city, then
03:13the camera and then the name. So we are getting it all coming in, perfect.
03:16So I'm going to hit Next and this takes us to our Data Set Options. This is
03:22where we can sort our information, rename columns, data type information. I'm
03:26going to go ahead and sort our columns by name, I'm going to sort them in
03:30Ascending order and that way the data is sorted by the name of the contributor.
03:35Now notice also I can filter out any duplicate row. So if you had multiple rows
03:39within this dataset, it would filter those guys out. And if you want to disable
03:43the data caching, you can do that here and you can set an Autorefresh rate, if
03:47you want to refresh that data every 5 seconds or 10 seconds or however long you
03:51want to update that.
03:52So I'm going to hit Next and that takes us to our third screen, which is the
03:56Insert Option. Now here is where we choose how this information should be laid
03:59out on to the page. Of course one of our options is not to insert it at all and
04:03if doesn't then the data is made available to us in the Bindings panel and we
04:07can use it by referencing that data anytime we want to in our code.
04:10So don't feel like you have to do one of these. But since it's so convenient we
04:13are going to go ahead and use this to insert a table with that information on
04:17the page. Now once you select one of those items, you will hit Set Up and that
04:21allows us to go into a dialog box and choose options for that specific format.
04:26In this case, I'm going to reorder some of my items here. I'm going to reorder
04:30it so that name is on top and that will be the first column and then I'll want
04:35city next, country next and then camera.
04:39We also have some really neat stuff down here as well. Notice that we can set
04:42classes for Odd rows, Even rows. The class currently selected in the Hover
04:46class. Well, I'm going to choose an Odd row class and I'm going to choose odd
04:50so, obviously this is CSS that I have already written.
04:53Now here we have a nice little Dreamweaver bug, you choose one of these guys
04:56and no matter what you use you are going to get the top level class whatever
04:59that may be. So you just have to choose it twice. You get in habit of doing it, trust me.
05:04We also have one other nice little thing here, Sort column when header is
05:08clicked. I really like that. That means that when somebody clicks on the header
05:12it will sort the data in the table by that. So again this is something that we
05:15can do through the use of Spry data. I'm going to go ahead and click OK and
05:20finally I'm going to click Done.
05:22There is our table. Now you don't see anything right now because we are not
05:24previewing the actual data. What you are seeing is you are seeing these
05:27placeholders, name, city, country and camera. I like the format of this table
05:31to look a little nicer. And I have already got some CSS in my site written to
05:35do just that. So I'm going to click anywhere inside the table and I'm going to
05:39click on the table tag in the tag selector. And using the Properties Inspector
05:43on the far left hand side, I'll grab the pulldown menu and assign the id of
05:47gearTbl to that. I'll go ahead and format that using styles that we already
05:50have defined in the site.
05:52So we'll now save our file and when we do that, notice that it's going to copy
05:55over the SpryData file, any xpath file, both of which are needed for our XML
05:59dataset. And then we can preview that in the browser. Cool, there is our list
06:05of contributors coming in from the XML file. There is our styling there is the
06:08Odd row class giving us that alternating row and the Hover is actually being
06:11done through the CSS but we could have certainly that through the Spry data as well.
06:15Notice that each one of these columns is sortable by clicking on it. We can
06:19sort it by that particular attribute which is very nice. And we got that
06:23through choosing the Sort option when we inserted the table on the page. Just
06:27to show you that this information is being brought in dynamically, I'm going to
06:30leave this Preview window open. I'm going to go back in Dreamweaver and I'm
06:34going to go into the contributors.xml. Just kind of copy one of these notes,
06:40paste it and I'm going to change some values here.
06:43So I'm going to change Max Smith to Megan Anderson and I'm going to change city
06:49from Baltimore to Ventura, which is where she lives. And by quirk of fate she
06:54has the exact same camera, so we'll leave that. So I'll do a save there. Go
06:59back into my browser and I'm going to refresh that data, and look there is Megan.
07:03So it is live and coming in and that's it, it really is that easy. The Data Set
07:09construction wizard in Dreamweaver incorporates the building, sorting and
07:12formatting Spry data all in one easy step-by-step process. Next step we'll
07:18explore creating another powerful Spry data type the HTML dataset.
Collapse this transcript
Understanding HTML datasets
00:00To me one of the coolest, most inventive, and powerful features of Spry is its
00:04ability to create HTML datasets. There are going to be plenty of times when you
00:08want to share data across pages without having to create a database or generate XML.
00:14HTML datasets allow users to use standard HTML tables and any other valid
00:19structured markup as a data source. This is a great feature for anyone who
00:23needs to re-purpose data from one page into other places in their site or for
00:27someone who may be new to web development who wants to use dynamic data, but
00:31might not be that familiar with XML or working with databases. Although any
00:35structured markup work, an HTML table closely resembles the structure with
00:40dataset and is a great place to start when learning to use Spry data.
00:44In this movie we'll use a table that contains a lot of information about the
00:47cameras I used, to create a smaller summary of those cameras on another page.
00:51We'll make the summary interactive and allow the user to determine which
00:55cameras information to display.
00:57The best part about this technique is that the summary will pull the
00:59information from the larger table at runtime, meaning if I changed the larger
01:03table, my summary will update automatically. And if I scroll down, I can see
01:08the table that I'm talking about. So here I'm on Camera Specs table and there
01:12are lot of Specs here, Zoom Wide, Zoom Tele, that will need that for the
01:15summary, but it would be good to grab this data.
01:17Now I want to point out something here that the CSS is sort of hiding. So I'm
01:21going to turn off my Style Rendering and to do that -- when I go down and look
01:26at this table again, you can see I have a header here that says camera and I
01:30have some text that says image that's hidden by the CSS. It's on purpose
01:34because when I create this dataset, I'm going to need labels for those items,
01:38camera and the image there. So that kind of has to be there for what I'm going to be doing.
01:42There is another thing I want to point out and that is that this table does
01:46have an id, gearTbl. So that is a another really important factor in this that
01:52if you want to pull information from a specific element no matter what that is
01:56whether it's a table or something else that element has to have an id in order
02:00for the Spry data to be able to grab it.
02:02So now I'm going to switch over to galleries.htm, you could find this on the
02:06same directory. And we are going to place our summary over here in the side
02:10bar. Now before we do that this is going to copy over some Spry assets for us.
02:14So we'll need to go ahead and reset our default SpryAssets directory. So I'm
02:19going to go over to my Files panel, find the name of my site and double click
02:22that. That will open up my Site Define dialog box. We'll go down to the Spry
02:29category in the Advanced tab, just going to browse out and I'm going to go in
02:33the 05_02 folder, find the SpryAssets and choose that.
02:38So again it's just making sure that's putting the SpryAssets in the proper
02:41location. Well, I'm going to go ahead and delete this line, summary data goes
02:45here. I won't delete the entire paragraph, just the line. And now I'm going to
02:48build my datasets. So I'm going to go up to my Spry Insert toolbar. I'm going
02:52to click on the Insert Spry Data Set and this time I'm going to leave it as
02:56HTML. And I'm going to change to the dataset name to dsGear.
03:01Now notice that when you are doing an HTML data type, one of things that it
03:04wants to know is what type of element do you want it to detect. It can look at
03:08divs, lists, tables or any other custom element. We are going to stick with
03:13tables because that is exactly where we calling the data from and then I'm
03:17going to browse to find the data file. Here we are going to go to Chapter_05,
03:2005_02 and I'm going to find that gear.htm. Click OK.
03:26Now I love this because it previews the data by actually showing you a preview
03:30of the page and then any element, in this case a table, that meets our
03:34requirements of having an id. It's going to have this little yellow arrow out
03:38by side of it and if I click, it sets that as the data source. I could also
03:42choose them from this pull down menu, but in this case our page only has one
03:45table with an id, so it's a pretty easy choice.
03:48Now as soon as you select that, notice that the Data Preview area down below
03:51that is now populating with all that data and it's bringing in everything. We
03:57also have this Advanced data selection where we can create rows and columns
04:01based on specific selectors. Now we are not going to filter out data this way
04:04yet, but we'll be doing that later on. So I'm going to click Next and that
04:08takes me to our Data Options.
04:10Now here I need to reformat this data a little bit. I kind of don't like this
04:16in terms of using this for a summary. So I'm going to go down into our Other
04:18Options and I'm going to click on the, Use columns as rows. When I do that I
04:23can see that I have a column for the camera, the image for the camera, all the
04:28resolution and that's going to be a little bit better presentation for a
04:32summary of our camera data then what we had before.
04:35Now I could sort these by the camera name, but I use the Sony more than the
04:38Fuji, so I'll leave the Sony on top. So I'm going to go ahead and hit Next and
04:42this time instead of inserting as a table, I'm going to insert the data as a
04:45master/detail layout. These are really cool because you will have your detail
04:50area and your master area. And the detail area will display detailed
04:53information about whatever is currently selected from master area. So you get a
04:57list on left hand side and as you click those items the detail region will
05:01update. So this is a pretty unique way of displaying a lot of data in the small
05:05area, just like we are doing.
05:06So I'm going to hit Set Up and the first thing it wants to know is what should
05:10the Master Columns be. I'm going to leave it as camera because that makes
05:14logical sense. The next thing I'm going to do is go down and filter out the
05:17Detail Columns. I don't want all this information so I'm going to start
05:21deleting some of these guys. For example, Low_Resolution, don't need it, going
05:25to highlight and hit the minus symbol. Sensor_Type, don't need it. ISO_Rating,
05:30going to get rid of that. Zoom_Wide, Zoom_Tele, Aperture_range, Storage_type,
05:36Uncompressed_format, pretty much everybody except for image, Max_Resolution
05:41Effective_Pixels and Weight.
05:43Notice also that I can reorder these if I want, but right now I think they are
05:47in pretty good shape. Now I'm going to change one thing here though. Notice
05:50that it's by default placing all of these items inside DIV tags. I'm going to
05:55change that and I'll place them inside paragraphs. So you can change the
05:59structure of this widget as it's being created as well which is just pretty
06:02cool. Click OK and then I'm just going to go ahead and choose Done, there we go.
06:08Now I'm going to Save this, notice it's copying over all the dependent files
06:13that it needs. And then I'm just going to switch to Live View to preview this.
06:17So here we have our summary information coming in, there is a Sony camera. When
06:22I click on the Fuji FinePix, I'm getting its information. So here is the
06:26master/detail region and it isn't working. Well, okay.
06:31So it doesn't look so great right now, but what rather you focus on is that we
06:34are pulling data from a table on another page and using it to build an
06:38interactive summary on this page. And as we'll see next, the two are linked, if
06:43we update our source table the summary regions will update as well. And you
06:46have got to admit that's pretty cool.
Collapse this transcript
Styling master/detail regions
00:00So currently, we have built an HTML dataset and then used that data to build a
00:05master detail region on our galleries page. Master detail regions are extremely useful.
00:11They allow us to display a large amount of data in a small area and
00:14their interactive nature encourages users to explore and consequently spend
00:18more time with that information. As with other Spry structures, the default
00:22styling is fairly basic, making it easy to customize to suit your own site's needs.
00:27In this example, our master detail region needs to be styled so that it can fit
00:31into the extremely small area we have chosen for it and so that it fits with
00:35the rest of our site. So, here, I have the galleries.htm page open from the
00:4005_03 folder. The first thing I want to do is examine the structure of the
00:45master detail region a little bit more closely. So I'm going to go over here to
00:49the sidebar and find our master detail region, and if you want, you can just
00:53sort of highlight a couple of items, so that when you go into Code View,
00:56it jumps right down there.
00:57So let's see what we have got here, oh, this is fairly simple. We have a div tag
01:01that surrounds everything with the class, MasterDetail. Then inside of that,
01:06we have another div tag with the class MasterContainer. So the MasterDetail
01:12surrounds the MasterContainer and the DetailContainer. So we have got
01:16one parent tag surrounding two containers. Now you will notice the addition of the
01:19Spry region and that tells Spry which dataset to pull the information from and
01:23then these are our data references. So that's telling us to pull the camera
01:26from this particular region. So very, very useful app.
01:29So we just have a collection of div tags, a couple of paragraph tags, and
01:33that's really all that's going on here, so there is not a lot to this.
01:37The first thing I'm going to do is I'm going to take this MasterColumn div tag,
01:40I'm going to change it from a div to a heading to. There is nothing that says
01:44that there can't be other structural elements. As a matter of fact, Spry really
01:48doesn't care what elements there are at all, and if I switch back to Design
01:51View, there is something else I need to take care of as well.
01:54This is going to be easier for us to accomplish with style rendering off. So,
01:57I'm going to use my Style Rendering toolbar and I'm going to turn Style
02:00Rendering off and then now I can see my master detail region even more
02:05clearly. So what I want to do is I want to label these items, maximum
02:08resolution, effective pixels, and weight. We are not really telling anybody
02:11what those are right now.
02:12So I'm going to click on the data reference here for maximum resolution and
02:15hit my Left Arrow key. It will place my cursor blinking just in front of that,
02:19and I'm going to type in the word, Resolution. I'll do a colon and then what
02:23I'm going to do is I'm going to hit Shift and then Enter. That's going to give me
02:26a line break and it's going to place the maximum resolution on a line below that,
02:29but still within the same paragraph. I'll do the same thing for effective pixels.
02:34So in front of that, I'm going to type in Megapixels and once again
02:37Shift+Return and then finally for weight, I'm just going to type in the word
02:42Weight, again Shift+Return. I'm going to go ahead and save that. Then I'll
02:47turn my Style Rendering back on again, and why don't we go ahead and preview
02:51that in the browser. So now it's looking a little better. We can't read our
02:56headings anymore because they don't fit into that space, but at least these
02:59guys are labeled - resolution, mega pixels, and weight. That's a little better,
03:02but we still have a little ways to go here. So what we are going to do next is
03:05modify our styles.
03:07So in my related files folder, I'm going to go find my SpryMasterDetail.css.
03:12I'm going to click on that, and again, I'm going to use the Split Screen View.
03:16Now I'm going to minimize my panels down to icons, so that I can see more of my
03:20code or more of my Design View, based on what I need. So I'm going to come over
03:23to the CSS and scroll down just a little bit and I can find the selector for
03:27MasterDetail, MasterContainer, and if you remember, this is the parent tag
03:31that's sort of surrounding both the MasterColumn and the DetailContainer as well.
03:35You can see what's causing some of our problems here with the 35%,
03:39floating them all to the left. So there is just no way for it to fit within
03:42that small little space.
03:43So I'm going to take all of those properties and I'm going to get rid of them.
03:46I'm going to replace it with a very simple property. I'm just going to type in
03:49color, #fff. So that will just make sure that everything is white, so that it
03:55reverses out very nicely against the green background. So I'm going to go ahead
03:58and save that, and that will help us out a little bit.
04:01Now I'm going to go down to the MasterDetail and MasterColumn. If you can
04:04remember, those are our headings over there and we have a font size and a
04:07background color, padding, and a cursor.
04:09Now the cursor is changing to a pointer, so that it knows that it's
04:12interactive, so that's kind of nice, but let's take a look at some of the
04:15things we are going to do here. We are going to take the background color
04:17property and we are going to get rid of that, so we don't really need to give
04:19it its own background color, we'll change its styling another way, but we are
04:23going to give those headers, a border underneath them.
04:26So to sort of identify what their content is, so I'm going to type in
04:28border-bottom and there we are going to do 1 pixel solid and then #fff to make
04:37that white. Excellent, I'm going to go ahead and save that, so that should be
04:41good. And I'm going to go down and find MasterDetail, MasterColumnHover.
04:46So remember that is, again, the hover attribute of these headings that we are
04:49going to be taking a look at and we are going to change the background color
04:52from this EAEAEA to 848484, so just a different shade a gray, to tell you the truth.
04:59The same thing for the MasterDetail MasterColumnSelected. We are going to
05:04change its background color too and it's going to go to #333.
05:08So a fairly dark gray if you would.
05:10So one more thing we need to change here, MasterDetail, DetailContainer.
05:14This is the div tag that contains the actual data, the image,
05:16the resolution, the megapixels, the weight. You can see, again, it has a width
05:20property, it has a float property. So there are some issues there that are
05:23affecting our layout as well.
05:25So, what I'm going to do is I'm going to get rid of all these properties as well,
05:28and we are going to replace them with background colors. So I'm going
05:30to type in background-color and that's going to be #768577 and then we are
05:40going to give it a padding of 10 pixels and that will help. Give it little bit
05:44of padding away from the text and edges of this. So, I'm going to go ahead and
05:47save that and we'll preview this in our browser, and you can see already
05:53that's looking a little better.
05:55We have got a nice little underline underneath those guys. We have some hover
05:58attributes that are already there. There is that gray, and there is that black
06:01that we had chosen, and you can see that now this is all fitting within the
06:05space. There is still some formatting that needs to be done though, and for
06:08this formatting we are going to go in and affect our main pages CSS.
06:12So let's go back into Dreamweaver and now I'm going to switch CSS files. I'm
06:17going to stick in Split Screen View here, but I'm going to go to this
06:19main_hasmenubar.css. So I'm gong to make this a little easier on you guys. Go
06:23ahead and scroll all the way down towards the bottom, all the way to the bottom
06:28of the code, and you will find at line 602, I have got a little comment, that
06:32says master detail specific styles go here. So just create a little blank area
06:37for us to write these styles.
06:39Okay, well let's try out our fist one. I'm going to type in '.twoColFixSnSide'.
06:41Now, that is Two Column Fix Small Side. That is the layout that we are using
06:53and I'm identifying those layouts by using a class attribute on the body tag.
06:57So, that's a very high-level selector. Then I'm going to hit Space and I'm
07:00going to type in #sidebar, that's the div tag that this is all inside of,
07:05#sidebar div.MasterContainer.
07:10So, notice that I'm referencing the Spry selector, here in my main styles,
07:16there is really nothing saying I can't do that. You can reference to CSS from
07:19any CSS file you want. So this is going to target the MasterContainer div tag,
07:24and we are just using a really, really specific selector, so that we make sure
07:27that these rules are followed. So I'm going to type in margin-bottom, and we'll
07:32do, 1 em, that will give us a little bit of spacing between them. And I'm going
07:36to do padding-bottom of 0, and that's just to overwrite some of the existing
07:41padding that's on some of our interior div tags.
07:44The next thing we are going to do is we are going to do #sidebar. You'll notice
07:47we are not having to be as specific now. div#check. And that is the id of the
07:54little sidebar module that we are inside of, Space h2, so it's going to target
07:58any Heading 2 inside of the check div tag. Now we are going to change our
08:03font-size to .8 ems. We are going to set the margin to 0. That will override
08:11any default Heading 2 margin. And we are going to give it a margin-bottom, of 1
08:17em. So again, that's going to just space stuff underneath it out a little bit.
08:21Next, we are going to do #sidebar div #check p, so targeting any paragraph
08:29inside of our check div tag. And that one, again, we are just going to do a
08:32margin-bottom, 1 em, and that will again push elements away from each other.
08:37Just give ourselves a little bit of vertical spacing there.
08:40And then next we are going to do, #sidebar. And again, we are going to
08:43reference some of those class selectors from Spry. So .MasterDetail, notice the
08:48capitalization there, that matters, Space.DetailContainer. So, once again we
08:53are targeting the DetailContainer inside the MasterDetail, inside the sidebar.
08:57So it's this little region, right over here, that we are targeting.
09:01And inside that, we are going to give it another background-color, and this
09:04background-color is going to be #768577, it's that green color. And again we
09:14are going to do a padding of 10 pixels.
09:17One more to go and that is going to be -- we are going to create a class
09:20selector called checkTitle. We haven't applied this yet. So creating the style
09:24is only half of what we are going to do here. We are going to do font-size and
09:29we are going to set that to 1.2 ems. We are going to do font-weight, and we are
09:35going to bold those and then for color, we are going to do #333. Whew! Man, a
09:39lot of CSS there, guys.
09:43The next thing we have to do and the last thing we have to do actually is I'm
09:47going to highlight each one of these little areas right here, resolution,
09:50megapixels, and weight. In highlighting them I'm gong to use the properties
09:53inspector to go ahead and apply the class checkTitle, the one that we just
09:57created to those guys. So do that to resolution, do it to megapixels, and do it
10:06to weight. Just be very careful and make sure you are only highlighting that
10:10and not the information underneath it. So we'll do save, preview that in our
10:15browser, and there we go, check it out.
10:20So there is our MasterDetail region. It looks great and we know it's being
10:24populated from our earlier gear table. Now, again, I want to prove that. You
10:28can see that the Sony camera there is listing its resolution as 4.9 Megapixel,
10:33really? Seriously? Not 5? Well, all right. So what I'm going to do is I'm going
10:37to go back into my site, and I'm going to open up the gear.htm, and this is the
10:40file that it is pulling that from, and I'm going into the table and change that
10:45from 4.9 million to 5 million or 54 million, that would be really good. So I'm
10:50going to save that. Now I don't have to republish this, or do anything else
10:53like that. I just have to save this.
10:55Now when I go back in the galleries, and I test that again you can see that in
11:00my Summary it now says 5 million Megapixels. So our MasterDetail region looks
11:04great and by populating it with the data from an HTML dataset we are using
11:08information, we already had on the site and even better, as we update our
11:12existing table or add new cameras to it. Our Summary will continue to update as
11:16well with no action required by us at all. So it's pretty low maintenance.
Collapse this transcript
Using non-table HTML elements for data
00:00While the structure of an HTML table is perfect for building data sets, you
00:04will sometimes find yourself wanting to build a data set out of information
00:07found outside of a table. That is not a problem as Spry enables us to build
00:12HTML data sets out of any HTML element type, even, as we'll see in this movie
00:16from multiple element types.
00:18The key to working with elements other than tables is in having a clearly
00:22defined structure to your data that Spry can successfully parse. With some
00:26elements like lists this is fairly straightforward, as an unordered list or
00:31ordered list are built using repeating structures.
00:34In other cases, creating the structure of your data and assigning relationships
00:38through Class and ID attributes is your job. In this example we need to display
00:43the three prints from the desolve.org site that are on special for this month,
00:47and list the title of the print, show a thumbnail, list the price and display
00:52the photographer's name.
00:53We already have this information on another page and here I have the prints.htm
00:57page opened, you can see what I'm talking about. Here we have the name of the
01:01print, we have a thumbnail, we have a description of it, we have the artist
01:05name and we have the price of it. So this is really all the information that we
01:08need and we have a full listing of prints. Of course, we don't need all these
01:12prints, we only need three of them and we only need the three that are on
01:15special for this month.
01:17So in order to figure out how we are going to build this data set, it's worth
01:21taking a look at the structure of our prints here. So I'm going to highlight
01:24all that, switch over to Code View, so I can see what's going on here. So each
01:29one of these is surrounded by a div tag. It has the class of printStory. Then
01:33we have a Heading 3 and it has a class of head to let us know it's the heading for that.
01:39Then we have an img tag and this img tag is in a Span tag that is floating the
01:44images to the left, so the text can wrap around it but notice that we have a
01:47class called floatLeft and we can take advantage of that as well.
01:50Our description is in a paragraph, we don't need that, so we'll just kind of
01:55ignore that. Although notice that the author right here is in another paragraph
01:59and it has a class of author that helps us with the styling but in the case of
02:03our data sets, it's going to help us build the data set too.
02:06And finally we have our price, which is in another paragraph, and again it's
02:09using a class to identify and style that.
02:12Now every single one of these prints has exactly the same structure repeating
02:17over and over again. So these are perfect candidates for building a data set.
02:21Now we only want part of the data. So what I'm going to do now is go into some
02:25of these prints and I'm going to go to the div tag and if you are following
02:30along with me, this is in the 05_04 folder, this is the prints.htm file.
02:35I am going to go in the Code View and certain prints I'm just going to choose
02:38them at random, I'm going to go to the very top, the <div class= "printStory">
02:42and I'm going to add the class of special to it. You will notice that it is not
02:47coming up because I don't have a defined CSS rule around it, but that's okay.
02:50I will go down and find another div tag with a class of printStory and I'm
02:55going to add the class of special to that. Now if you have never done multiple
02:58class attributes on one item, there is no comma, it's just a space between
03:02them. And finally I'll go down and find another one and we'll give that one a
03:08class of special as well.
03:10So now that our data is properly formatted we have identified just the ones we
03:14want with the class of special we can go ahead and bring those guys in. So what
03:19I'm going to do is switch back to Design View and I'm going to switch to the
03:22speicals.htm file.
03:25Okay so now I'm going to go and scroll down and I can see on this page that we
03:28have a little section here where our spotlight prints are going to go and below
03:31that we have a place where they are showing the featured product of the month
03:34but we are really interested in a spotlight prints area.
03:37So I'm going to place my cursor just after this month's spotlight prints,
03:40create a little empty paragraph down there for it and I'm going to go up to the
03:43Spry tab on my Insert toolbar, click the Spry Data Sets and we are going to be
03:47building an HTML data set here.
03:49Now the data set that we are going to be using is dsSpotlight because we are
03:53spotlighting certain prints and last time you will notice we said that we were
03:57going to detect tables, this time we are going to detect div tags.
04:00I am going to go and specify the data file, so I'm going to browse and I want
04:04to browse to the 05_04 prints.htm page, now remember we just updated that page
04:10and wow, all of a sudden we get all these markers all over the place.
04:13Well any div tag with an id you are going to be able to use. Now frankly
04:18getting this right by clicking the arrows can be sometimes a little difficult,
04:21so I'm going to go over to this pull- down menu for Data Containers and instead
04:24of trying to pick a specific div tag of one print, we want all the prints, so
04:28I'm just going to use their parent div tag mainContent.
04:32Now when I do that, in there you see a jumbled mess down here in the Data
04:35Preview because everything inside of the mainContent div tag is sort of flowing
04:39into this one single column layout. Well we need to filter this data because we
04:43are looking for some very specific things.
04:45So that's where these advanced data selectors come in. These are very nice. I'm
04:48going to go ahead and click this little checkbox for Advanced data selection
04:52and remember to create our rows, we used that special class to do that. So I'm
04:57going to type in .special and you actually type in whatever selector you want
05:02to filter this by and this is CSS based selectors, classes, ids, tags, whatever
05:05you would like.
05:06When I do that and hit Tab, you don't want to hit Enter but you want to hit
05:09Tab, you will notice the data updates and now I see only three elements and I'm
05:14seeing the three prints that I we identified as specials.
05:16Well now we need to break them up into columns and to do that, we are going to
05:20use some of the additional selectors and their class attributes to pass in just
05:25the items that we want. So here we are taking advantage of the existing
05:28structure. So for a Column Selector, I'm going to choose h3, span.floatLeft,
05:38.author, .price.
05:42You can think of it like writing a really big group selector because that's
05:45kind of what you are doing. I'm going to hit Tab. It will update that and look
05:48at this. Now we have a table of data. So we are filtering out from this much
05:52larger page, just the three prints that were specified with a special class and
05:57then we want the image, the author, the price and the title and we are getting
06:01all of that by passing these individual selectors as well.
06:05Now I want to pass one more little piece of information about this. When you
06:09pull an image and you want the actual image tag, don't use the image tag as one
06:13of the selectors. If you want the image, it has to be surrounded by a parent
06:17tag because what you are pulling in is the contents of the tag, not the tag
06:20itself. That is why we have the span tag around the image and that's why we are
06:24using the span tag to float it to the left rather than just float the image
06:27itself to the left. So I'm going to click Next.
06:30Now we get to do some of our data set options. Now when you create a custom
06:33table like this, it doesn't really name the columns anything that makes sense,
06:37so we are going to go and change those. I'm going to click in the first column,
06:40all right, up here where it says Column Name I'm going to name that title. I'm
06:43going to click in the second column and I'm going to go ahead and name the
06:46image, I'll click in the third column and I'm going to name that artist and I'm
06:52going to click in the fourth column and I'm going to go ahead and name that price.
06:56Be very careful about hitting a Return or Enter, it will close this out, you
06:59really don't want that. Sometimes you get in the habit of doing that when you
07:02type something in. Remember the Tab key is your friend with this.
07:05So there we go, that's looking pretty good. What we are going to do next, we
07:08are not really going to sort this, although I guess I could sort it by title
07:11and let's do that. I'm going to click on title and I'm going to sort it by the
07:14title column. Here we go.
07:16Now I'll hit Next and in terms of my data options and how I want to insert
07:21this, I'm going to insert it using the stacked containers with a spotlight
07:23area. That will allow our thumbnail to be the spotlight area and all the other
07:27information will show up on the right hand side of it. So that's pretty cool.
07:29Now of course we want to do a set up on that and remember at the spotlight
07:33columns, I don't want the title, I want the image. So I'm going to click plus,
07:36choose Image and then I'm going to get rid of the title. So I just want image
07:39there for my Spotlight Column.
07:41If I go down to my Stacked Columns, I'm going to go ahead and add my title to
07:45that and you can reorganize these guys as well. I'm going to take image and get
07:48rid of that and now I just have title, artist and price and if I needed to I
07:54could use these arrows to move those up and down. Now I'm going to take title,
07:57I'm going to format that as a Heading 3. So the title will be an h3 tag,
08:01whereas my artist and my price are going to be in Paragraph tags.
08:05All right, looking good. So I'm going to go and click OK, I'm going to click
08:09Done and I'm going to just save the file. Now you will notice that the
08:13SprySpotlightColumn.css is being added to my Spry Assets and if I preview this
08:18in my browser, you can see that all three of these guys are coming in. So there
08:23is some default styling that I don't like here at the border end but that's
08:26pretty easy to remove. Everything else is looking pretty good.
08:29Now you will notice that it is bringing in just those three prints, the ones
08:33that we identified as specials. So if we were to go back into prints and change
08:37that so that maybe this one was no longer special this month, so I'm just going
08:43to bring up the Quick Tag Editor and get rid of special, so this is Orange Walk
08:48and I'll change the two towers and actually you know what I really like this
08:53image of Charlotte, it's a Bullish of Charlotte, so we'll do this one, we'll
08:56grab it's div tag and I'll identify that one as special.
09:03So every month you can just some in here and change those class selectors. You
09:06can save that, preview that in a browser and now you can see it's bringing in
09:11that print instead. Awesome!
09:14Now if we wanted to we could certainly go into our SpotlightColumn.css and find
09:19that border that has given us such trouble, there it is right there. So maybe
09:23we just don't want that border and remember you can modify those anyway that
09:27you want. I would really recommend that you go and you kind of play around with
09:30those and find out what you don't need and what you don't like and you can
09:34comment certain things out and delete other things and just save that, strip
09:39out those borders, preview it again and now we don't have any border around it
09:43and we don't have any borders around those items. So that's looking more of the
09:46way that we wanted it to look. Perfect.
09:49So our repeating div structure with a little help from some class attributes
09:53allowed us to build a Spry data set that is now powering our monthly specials
09:56print list. While it's extremely easy to filter data this way, keep in mind
10:00that consistent structure is crucially important to making this work and that
10:04class attribute is going to help you filter out which elements are brought into
10:07the data set and which are not.
10:09Remember as well that if you want to add an image as part of your data set, it
10:13needs to be inside a parent element to work correctly. It's also a good idea to
10:17name your columns as you build the filtered set referencing that data could be
10:20tricky if your columns are named column1 column2, column0 and so forth. Other
10:25than that building HTML data sets are an easy way to reuse data across sites
10:30and speed development time.
Collapse this transcript
Using Excel spreadsheets to build datasets
00:00Spry is full of surprises, especially if you really get in and dig around the
00:04documentation. Although not integrated into Dreamweaver, Spry has a
00:08capabilities to build datasets out of many objects and file types such as JSON
00:12objects, CSV and TSV files.
00:16Being able to build datasets from comma and tab delimited files means that
00:20anyone in your organization with access to Excel or any type of spreadsheet or
00:24word processing application can build and modify datasets for your website.
00:29That, my friends, can save you a lot of time.
00:32As usual the same warnings apply. If someone who has JavaScript disabled
00:36browses your site, they won't be able to see your data. Because of this you
00:40should be careful about using Spry to display critical data or at least give
00:43the user alternate access to it. For us to build the Spry CSV dataset, we'll
00:48have to leave the cozy confines of Dreamweaver Spry toolbar and so a little bit
00:52of hand coding. Don't be nervous, it's actually very simple. It gives you a
00:56front-row seat to what Dreamweaver has been doing in the background as you have
01:00been creating your Spry datasets.
01:01Regardless of the dataset type, the code used to construct them is extremely
01:05similar. So learning the hand code one type makes it a lot easier when you want
01:10to learn how to do other types. We'll also have to do one more thing that
01:13Dreamweaver has been taking care of for us. We need to include the related Spry
01:16library files that it needs to build our Spry dataset.
01:20Here is where carefully researching the online Spry documentation pays off and
01:25what we want to do is we want to create a dynamic table of when the artist will be
01:30in a certain city. Now we actually happen to have that in a comma delimited file.
01:34Very convenient, huh?
01:36So, I'm going to open that up in Excel. Feel free to open that up in any
01:39spreadsheet application you have and notice that I have got City, Date and
01:45Artist columns and it explain the Dates, the Artist and the City. Notice that
01:50City, Date and Artist are all capitalized and that's going to come into play a
01:53little bit later on. So I'm going ahead and close that and don't save any
01:57changes if it prompts you.
01:58We are also going to need to have our Spry Assets. So I'm going to go into the
02:04Spry Release that we have downloaded and unpacked earlier in the title.
02:09If you haven't done that yet, I would recommend going back and checking out
02:12downloading the Spry Framework from Adobe and unpacking it. So you have access
02:16to these files and I'm going to look in the Includes folders and find the
02:20SpryCSVDataSet file. We'll go ahead and select that, hold my Ctrl key down and
02:26I'm going to move that up and copy it to the 05_05 SpryAssets folder. It should
02:32copy right in there now.
02:33We are also going to need the SpryData file to do this as well but it's already
02:37in there. If it wasn't, we would have to copy that one as well. Okay, well
02:41everything we do from this point forward, it can be done in Code view. So I'm
02:44going to back to tour.htm, switch over to Code view and go up and let's go
02:48ahead and code this.
02:49Now I'm big believer in copying and pasting and you can see we have a script
02:53tag that's linking us here to the SpryMenuBar.js. I'm going to ahead and
02:57highlight that, copy it and I'm just going to paste it twice.
03:02Now, at first I'm going to bring in my SpryData.js and the order that you bring
03:07these in is actually very important. The CSV dataset calls on functions from
03:11the Spry dataset, so I'm going to make sure that's brought in first and then
03:15below that, I'm going to change SpryMenuBar to SpryCSVDataSet.js. It's going to
03:24go and grab both the data file and the SpryCSVDataSet file and bring those in.
03:28So that's good.
03:29Now we have access to those JavaScript libraries and let's scroll down to the
03:34very bottom of the code and I can see I have another script tag down here,
03:37where I have a constructor function building our menu bar. They are kind of
03:41like putting all my constructor functions in the same place, so just below the
03:45line where we are building our menu bar, we are going to have to do a little
03:47bit of JavaScript work here, not much and if you have never done it before, you
03:51will be surprised to how easy this is.
03:52I am going to type in var. That's the var keyword that allows us to create
03:56brand new object types and I'm just going to go ahead and type in dsDates = new
04:05and here is where code hinting is going to help us out again. I'm going to type
04:07in Spry and a dot and right up comes code hinting and .Data.CSVDataSet.
04:15So it certainly recognizes it because code hinting allows us to access it.
04:18So that's nice. And inside that I'm going to just tell it where to go find that,
04:22so I'm going to in parenthesis, tell it in quotation marks to go
04:25"_xml/dates.csv" so it point directly to the CSV file.
04:35Now go ahead and close your quotation mark, your parenthesis and then type in
04:38semicolon, so that it stops evaluating that line because that line of
04:42JavaScript is done. We are going to save the file and now we have constructed a
04:46brand new data set. We have told it where to find the data and we have told it
04:50which libraries are needed to process this Spry data and the Spry CSV dataset
04:54files. So all there is left to do is code our tables so that it can display this data.
05:00Now if you remember from your discussions earlier, if you wanted to display
05:02Spry data on the page, you need to have a Spry Region. So we need to surround
05:07these entire tables with the Spry Region.
05:09So I'm going to highlight all of these Table tags, click on the Tag Editor over
05:13here so that it can wrap this tag with a Div tag and I'm going to give it an ID.
05:18And I'm just going to give an id of datesRegion, although I could have
05:22named this anything that I wanted to. That really doesn't have any thing to do with Spry.
05:25However, the next thing does. So the next thing, I'm going to type in
05:28Spry:region and the Spry Region wants to know which dataset I'm going to be
05:34pulling from and I'm going to pull from the dsDates dataset. So if you have
05:38multiple datasets there, we would want to tell that which one we were going to
05:41pull from. If you are wondering, yes you can pull from multiple datasets in one
05:44region, there is nothing wrong with that.
05:46So we have now identified this table that's being inside of the Spry region and
05:51now we need to deal with the repeating nature of this. So every time there is a
05:55new item inside my dataset, I want a new table row.
05:59So I'm going to go into the second tr tag. Again I'm going to do Spry but this
06:03time I'm going to do a repeat region and this repeat region is again going to
06:07be pointing to dsDates. So we have two Spry regions going on; we have a Spry
06:11region that allows us to display data anywhere inside the table, but inside
06:15this table row, it's a repeat region. So every time it finds a new item inside
06:19the dataset, it is just going to create a brand new table row for us.
06:22Now we need to replace these non- breaking spaces with what we call data
06:25references. So here I'm going to type in a curly brace and capital C and I'm
06:29going to type in City. Then I'm going to in curly braces, type in D for Date.
06:37And then in curly braces, I'm going to type in capital A and then Artist.
06:41So what's going on here? Well the curly braces indicate that this is a data
06:45reference and it's basically telling Spry, "Hey, look in the dataset and find
06:49this column of data," remember in the CSV file, the Artist, Date and City were
06:54capitalized so that's case- sensitive and we are returning that here.
06:57Normally you can look in the Bindings Panel and you can see what all these are
07:00named but since this is a CSV dataset, Dreamweaver doesn't do that for us. So
07:04I'm going to go ahead and save that and then we have one last little thing to
07:08take care of. This is a minor housekeeping detail, I would love it to make it
07:11to where you can click on City, Date and Artist and sort the table. Well that's
07:15very simple to do too.
07:16So I'm going to go up to my headers and inside of the th tag, I'm going to do a
07:20Spry:sort and I'll sort the first one by City and then for the second one, I'll
07:25do another Spry:sort. I'll sort down by Date and then finally we'll do another
07:31Spry:sort and we'll sort that by Artist.
07:34So that way if somebody clicks on that header, they will go ahead and sort by
07:38that information. So I'm going to go and save all of that, preview that in my
07:42browser and hey, look. There is our data coming in from our .csv file and
07:48notice it is sortable. I can sort if by Artist, Date or City. How cool is that?
07:56As you can see, once you know the structure and syntax of Spry,
08:00it's surprisingly easy to hand code. Having our CSV file supplying the data is pretty cool,
08:05since anyone with a spreadsheet or word processing application can now
08:08update and upload the new data for us without needing our input and
08:12how much time is that going to save you? Really, really cool.
Collapse this transcript
Hiding unloaded data references
00:00I have always said that it's the little thing to count and that is certainly
00:03true in regards to this movie. When you are using Spry data on a page,
00:08occasionally there might be a brief pause between the page loading and the time
00:11that it takes the data to load. During that pause, the data references in your
00:15code and that's the text surrounded by this curly braces that tells Spry which
00:19data to use, well those are going go be visible to the user.
00:22This pause is usually very, very brief, sometimes so quick that you wouldn't
00:26notice it at all and in some cases you might feel like the amount of data
00:29loading is so small to worry about dealing with this and then in other cases,
00:33you might want to make sure that this doesn't happen.
00:35It's really a personal choice. My own opinion is that anything that you can do
00:39to make the user experience better and more seamless, well you should do that.
00:43There are actually several techniques that you can use to hide unloaded data
00:46references from users and if you are interested in learning more about it, you
00:50can read up on these techniques on Abode Spry documentation sample pages.
00:55The technique we'll use is the one that I consider to be the easiest and the
00:58most non-technical. To use it, you just have to know how to apply a class
01:02attribute and write some simple CSS. So I have the tour.htm file opened and I
01:07want to point out a little bit of scripting change here. If I go up to the head
01:12of the document, we see that there is some new JavaScript code just has been
01:15added to this. So I'm registering a new observer, so when the page finishes
01:19loading, it's going to fire of this alert, which is 'click OK to load the table.'
01:24Well once the user clicks OK, it's then going to go out and create the new Spry
01:28dataset. So that will create a pause between when the page loads versus when
01:33the data loads and that's going to allows us to see what the user would see if
01:37the data was loading slowly. So I'm going to go and preview that in my browser
01:42and right here you are seeing those data references. So if there is any type of
01:46pause between the page loading and the data loading, that's want the n user
01:49sees once the data loads, those go away and they see the actual data. Now
01:54usually that happens so quickly that you can barely register it but on slower
01:58connections or if there is a really a lot of data that's being filtered, that
02:02might actually take a little bit longer.
02:03So how do we hide that. Well, as I have mentioned, there are several different
02:06methods but there is one really super easy method and that involves a class
02:12called SpryHiddenRegion.
02:14Now data is loading up dynamically. What happens is as soon as Spry finishes
02:19loading the data, it looks all the way throughout your page for anything with
02:22the class attribute SpryHiddenRegion. If it finds that class attribute, it
02:27removes it. So what we can do is we can write a simple selector that uses that
02:32class to hide elements, knowing that class attribute will be stripped out once
02:36the data loads and anything that wasn't visible will suddenly be visible. It's
02:40a really unique technique and you can see right in my code here, I have an
02:44embedded style called SpryHiddenRegion and it has the visibility attribute set
02:50to hidden. So this is an embedded style, it's probably something you want to
02:53put in your external style sheet, but you just want to have that selector
02:57available for any region that's going to have data loaded into it.
03:00So I'm going to scroll down into my page and I'm going to find my
03:04sprydsDatesRegion and that's where I want to apply this class. So I'm going to
03:10type in class and I'm going to type in SpryHiddenRegion. It picks it up because
03:15I have got it defined above that and that's all you need to do. So you just
03:19need to have the class attribute assigned to a Spry Region and you just need
03:23the CSS that's actually going to hide it. So that is extremely simple; once the
03:29data loads, Spry is going to go all the way through the page and nay elements
03:32it finds with that class, it's going to strip that class out so that the
03:35element will be visible. So I'm going to go ahead and preview that in my
03:39browser and now you can see no table at all. So no hidden data reference, no
03:43table, as soon as the data loads, table shows up, the data appears on the page.
03:48There might be a brief flicker where the data loads but we won't see those
03:51hidden data references.
03:53That is really simple. As a matter of fact, this technique is almost too easy.
03:58I can't think of a reason not to use it. It manages to hide all unloaded data
04:02references by simply applying a class and writing a style that keeps that
04:06content hidden. It is usually the small thing to separate the good sites from
04:10the great sites and this is a very small thing that can make a noticeable difference.
Collapse this transcript
6. Hand-Coding Spry
Taking Spry beyond Dreamweaver
00:00Although Spry and Dreamweaver are well integrated and designed to work
00:03together, if you only stick with the Spry capabilities that are built into
00:07Dreamweaver, you are missing out on a lot of powerful features that Spry
00:10offers. Also, regardless of how fast Dreamweaver's automatic insertion
00:15processes are, once you have mastered hand coding Spry you will be much faster
00:18when building your applications by simply dong them by hand.
00:22Even if you are not a JavaScript wizard or a strong Web developer, learning to
00:25code Spry by hand will make you more comfortable with what is being done
00:29behind the scenes as Dreamweaver helps you build your pages.
00:32It also helps to reveal this simple truth that Spry content is really just
00:36collection of well-structured XHTML, CSS, JavaScript and the occasional use of
00:42XML or other types of data sources.
00:45As long as you let Spry's JavaScript libraries handle the functionality,
00:48writing the corresponding XHTML and CSS is really pretty simple.
00:52In this chapter, we'll revisit a widget I showed you how to build in an
00:55earlier lynda.com title, Dreamweaver CS3 Projects: Creating Custom Spry Widgets.
01:01I'm returning to this widget because it's a perfect example of how to take Spry further.
01:06The Sliding Panels widget is not included within the Dreamweaver's Spry tools
01:10and can only be created by hand. It's the perfect way to learn how to
01:14structure, code and style custom Spry content and we'll take this example one
01:19step further than my previous project by making the widget data driven,
01:23making it even more powerful and simple to update.
01:26I just want to preview this on my browser to show you what we are going to be
01:30building. So if I scroll down little bit, we have what we call a Sliding Panels
01:36widget here and we have four thumbnails of items that are on special and if you
01:40click on one of the thumbnails, it animates to that item and you will notice
01:45there is a nice little animation happening and the content blurs as it animates,
01:49so this is a really cool little Sliding Panels widget.
01:52Let's take a look. If I scroll down in my code, I can find our widget, which
01:58doesn't look so good in Dreamweaver's default view and let's take a look at
02:02exactly how much code that takes. So here are our thumbs and there is our div
02:08tag and that's it, 16 lines of code.
02:12In addition to that, of course, we have the links to our external assets and
02:15we have a constructor function, but really that's it. So, before we get
02:21started we want to make sure that we have the proper Spry Assets and again we
02:25are going to do something that usually Dreamweaver does for us.
02:27I am going to go into my Spry library, so I'm going to open up the Spry
02:30Framework that I downloaded from Adobe, again if you have not done that yet, go back
02:35and watch the movie on downloading the Spry Framework and installing that and
02:39then you will be able to grab these files along with us.
02:41So I need a couple of files here. Now the first thing I need to do is I'm going
02:45to go into the includes folder in the Spry Framework and I'm going to grab
02:49these SpryData.js and I'm going to grab xpath.js because our data is
02:55going to be coming from an XML file, so I need both of those. And I'm going to
02:59copy those up into the 06_01 SpryAssets folder and I notice that SpryData is
03:06already there, so I'm going to say No. And I'm also going to go down and not in
03:11the includes this time, but I'm going to go into the widgets and notice that all of
03:15our widgets are in here and there is a Sliding Panels widget, so I'm going to
03:18grab that and I need to grab the SprySlidingPanels.js and the SprySlidingPanels.css.
03:25If you are wondering what that HTML file is, that is a sample file that you can
03:28open up and take a look at how this widget is constructed and I'm going to copy
03:33that in the 06_01 SpryAssets folder as well.
03:36So now, all of our Spry Assets are in place and ready to use on our page. So,
03:41while this application really isn't that different than anything else we have
03:44done up to this point, it's a little different because we are going to build it
03:47manually from the very beginning,= all the way to the end of it. Since our
03:51component will be data driven, the data itself is a logical starting point and
03:55is the next thing that we are going to built.
Collapse this transcript
Writing XML
00:00Most of the XML files you will use will probably come from another source.
00:03It's quite easy in fact to have server-side applications based on PHP,
00:08ColdFusion or .Net create XML for you based on an existing database, or return form data.
00:14In fact, Adobe has several sample scripts for generating server-side XML within
00:18the Spry documentation. There are times, however when you might need to do it
00:21yourself. Much like XHTML and CSS, Dreamweaver helps to make the process of
00:26hand-coding XML faster by giving you eeal-time code hinting based on your
00:30current tag structure. As soon as you add a tag, Dreamweaver remembers it and
00:34adds it to the Auto-complete list and if you have never written XML before,
00:38relax. It's extremely easy for anyone who has a solid working knowledge of HTML.
00:43The syntax rules are almost identical to HTML; you must have probably missed
00:46your tags, all tags must close and all attribute values must be in quotation
00:50marks. So what we are going to do is we are going to go in the 06_01 folder and
00:55I'm going to open up this _xml folder and there is actually a couple of things
00:58we are going to do here. I'm going to open up specials.xml. This is going to
01:02describe all of the products that are on special for us and I'm also going to
01:05open up descriptions.txt. Just like any good cooking show, we have a couple of
01:11things that are already done to save you a little bit of time.
01:14So let's take a look at our specials. xml file. So the root tag of this XML file
01:19is products. Notice that it has a name space declaration and this is pointing
01:23to some place on our site where the skimmer would be listed. So there is our
01:27products and there is a closing products tag, then inside that we are going to
01:30have repeating structure of items.
01:33Notice that the item has a name and an index value. The index value is going to
01:37help us keep count of our products. We'll also have a description and a price
01:42and a thumb. We are going to add a couple of things to this but I want to make
01:45a point here about a few things.
01:47First of our description and our price is surrounded by something that we call
01:51a CDATA tag; you can see here's the opening CDATA tag, here is the closing part
01:55of the CDATA tag. Now what does that do for us?
01:57Well the CDATA tag is going to take any special characters inside of it, like
02:01dollar symbols or percentages and it's going to ignore them, it will not parse
02:05the. So if you had actually written an h1 tag in the middle of that, it
02:10wouldn't try to parse that if it's an h1 tag, it would just represent it as a
02:13literal string. It's very helpful if you ever have code examples that you need
02:17to display and you want the XML parser to ignore those. So CDATA tag is
02:22something you must spent a little bit of time doing.
02:23For my own personal use, I have created to snip it out of them so that I can
02:27highlight any copy and then just go ahead and surround it by CDATA tag. Now
02:30there are a couple of things I want to change here. First of, I'm going to take
02:33this $50 and get rid of that because well, that's part of the price. So inside
02:37the description, highlight the $ 50 at the end of it and delete it.
02:40When you are working around the CDATA tag, though make sure you don't ever
02:43delete any of the opening tag or the closing tag. It's really easy to find, you
02:47have got this left bracket and right brackets and those guys, you want to stay away from.
02:51There is a couple of things we want to add here too at the very bottom of our
02:55item tag but still inside of it, right after the thumb as a matter of fact. I'm
02:59going to hit Return and I'm going to open up a new tag. You will notice that
03:02because of the previous tags, the Dreamweaver's catalog it's like pull the odd
03:05description out of price products or thumb? Well, I don't want any of those. We
03:08are going to make up a brand-new tag.
03:10It's a beautiful thing about XML. If you don't have a tag to do something you
03:13need it to do, you can make one. So we are going to create a panel tag and then
03:17inside the panel tag, our initial value is going to be panel0; notice that,
03:22that is all lowercase and there is no spaces there, panel0 and now I'm going to
03:25close the panel tag and notice that Dreamweaver has closed that for me because
03:29it's like okay, you want to close the panel tag. What's this going to do for us?
03:32Well, when we are calling out Sliding Panels widget, that identifies which
03:36panel is sliding, so we are keeping count. index of 0 and a panel of 0, that's
03:40going to help us with our function.
03:41Next thing we are going to do is we are going to place in an id and the id for
03:46this particular item is going to be hoody and all lowercase. So again, that's
03:50going to be unique id that identifies which element we are dealing with. We can
03:54also use our name for that but we wouldn't be able to be quite as descriptive here.
03:59So I'm going to go and save this file and I'm a big believer in copying and
04:02pasting. We have four items, we need four item tags. I can go ahead and copy
04:07that and I can paste that one, two, three more times. So now we have four items
04:15and all we have to do is change the data in each one.
04:17So I'm going to go down to the second item tag. You can identify those by that
04:23opening item tag right there and I'm going to change the name from Desolve
04:26Hoody, and I'm going to change that to AsterRisk T-Shirt. Its index value of
04:36course is going to be 1.
04:37Now to save your little bit of typing, I have given you this text file and I'm
04:41going to copy the description, the second description here, we are going to
04:44highlight that paragraph and copy it and then I'll replace the existing one
04:48inside the CDATA tag with that one. Again, be careful not to replace the
04:52opening or closing CDATA tags.
04:54Now I'll save that. Now the price for AsterRisk T-Shirt is going to be $18 and
05:01the thumbnail instead of the hoody_sm. jpg is going to small_tshirtFront. You
05:13would want to type this carefully, so you might want to pause the ,movie
05:16occasionally and just type the stuff in because all of this stuff is very
05:19important. If this link is not written correctly, then we won't get to see our
05:24thumbnail image, so it's very important.
05:26The panel for this one is going to be panel1 and the id for it is going to be
05:31tshirt. So you see, we just have a repeating structure and we just have to make
05:36sure that we are being careful and meticulous as we go through this.
05:40The third item is title and so Desolve Hoody is going to be Desolve Messenger
05:48Bag. So Desolve Messenger Bag. Its index value is going to be 2 and I'm going
05:55to go copy its description and paste that into its description tag as well.
06:03Again, be very careful around that CDATA tag.
06:06The price of our Messenger Bag is $75 and the thumbnail for that, I'm going to
06:13go ahead and highlight this hoody_sm right here as bag_sm. It is panel2 and its
06:22id is going to be bag. So far, so good, and one more item to go.
06:27Our last item's name instead of Desolve Hoody is going to be Long Sleeve T and
06:35its index value is going to be 3. I'm going to go over the text descriptions,
06:41copy that one and then paste it inside my CDATA tag. Perfect.
06:48Now the price of our Long Sleeve T is going to be $25 and the thumbnail for
06:52that one instead of the hoody_sm is going to be longt_sm. Panel for that one
07:00would be panel3. Even though it's the fourth panel, we started counting at 0
07:04and the id will be longT as well. So I want to make sure I didn't make a
07:09mistake, so I'm going to go back up and I'm going to see that we have an item
07:13name index for each one of these guys.
07:15I am really interested in the ones that I have changed here, so AsterRisk
07:19T-Shirt index of 1, here is my CDATA tag. It's intact. I have got my price
07:25inside it. CDATA tag, it's intact. This is panel1, tshirtFront. Well, that's
07:31looking good, there is my id. Desolve Messenger Bag, its index value is 2, its
07:35panel is 2. So the index and a panel value should match. It's $75. It's all
07:40looking good. The same thing around Long Sleeve T.
07:42So now we have an XML file that describes our monthly specials. I'm going to go
07:46ahead and save this. It contains all the necessary information to describe our
07:50products and display the thumbnails even better, the XML structure makes it
07:54easy to add new products or to revise existing ones.
07:57Now that we have our data, it's time to return to our Specials page and build
08:00the structure of our Sliding Panels widget.
Collapse this transcript
Coding widget structure
00:00When Dreamweaver inserts Spry widgets on to your pages, there are a lot of
00:03things that happen behind the scenes. Links and script tags are added to the
00:07header of your document, constructor functions are added to create new instance
00:10of your widget. And all the XHTML structure necessary for the widget to
00:14function is automatically added to the body of your code.
00:18Because we are not saying that if you are building your own widgets from scratch
00:20all this is your responsibility. That's why it's so important to
00:24understand the necessary structure of your widget prior to building it.
00:27Adobe's online documentation is very good about giving detailed information
00:32about the tags, IDs, and classname attributes that are required for each widget
00:36to function properly. And it should be the starting point for any Spry based project.
00:41Since we are working on a Sliding Panels widget, it would be worth our time to
00:44discuss the necessary elements on page prior to adding the code. Like most widgets,
00:49the actual required structure is pretty simple. You need an outer
00:53container with the class attribute Sliding panels, an inner container with the
00:56class attribute Sliding panels content group. And then finally as many
01:01container tags as needed to service the panels themselves.
01:04All elements must also have ID attributes. Although this can be of your choosing.
01:09The majority of the time those container elements will be Div tags, although you are
01:13free to use whatever tags you would like.
01:15Another important part of the Sliding Panels widget are the links that are used
01:18to animate the panels. These can be any links at all. In our example we'll be
01:22using our thumbnails as links. We'll go ahead and add the structure for our
01:26thumbnails, while we build the widget structure as well. So we'll go ahead and
01:30do both of structural elements. And I'm just going to immediately switch over
01:33to Code view because we are going to be hand coding our widget.
01:36Now I'm going to go ahead and scroll down and starting on line 77, all the way
01:44through line 85 I'm going to delete those. And what is that? Well, in Design view,
01:48these were our feature products. So rather than doing a feature product
01:51every month, they want to display whatever items are on special.
01:54So, I'm going to go to Code view and we are just going to go ahead and move it
01:58that out of there. So, right there in that empty space that we have created,
02:02we'll go ahead and add our widget structure. Now, before we add the widget
02:05structure, we are going to add the structure for our thumbs. I'm going to go
02:08ahead and create a div tag and I'm going to ahead and give that an id of thumbs
02:12and I'll close that div tag. And I'm very contentious about opening a tag and
02:19closing a tag. It prevents me from forgetting the closing tag a little bit
02:22later on, which is very easy to do.
02:24Next, I'm going to add a span tag and I'm going to give that an id of thumb
02:31regions. So this should give you some idea as to what we are going to do later
02:33on with our Spry regions and then I'll close the span tag. And then I'm going
02:38to open up a link tag. Now this is going to have href attribute and instead of
02:44actually linking to a page it is going to activate one of those panel.
02:47So I'm just going to go ahead and give this a JavaScript, no link and we'll
02:50type in javascript:void and then pass in 0 in the arguments. So, that's not
02:56going anywhere. And we'll go ahead and do a semicolon there. And that's very
03:00useful guys if you ever need a link to be a no link and you want to click and
03:03activate something which you don't actually wanted to go anywhere, reset it to
03:07the top of the page, this is a handy way of doing that, that's as a JavaScript
03:10and no link.
03:11So after that I'm going to type in space, I'll do a little bit of a title here
03:15and for title, I'm just going to type in placeholder and that seems really
03:18weird but anything that says placeholder is eventually going to be filled with
03:22dynamic data. After that we are going to go ahead and close the link tag, and
03:28then inside the link tag, I'm going to open up an image tag, IMG.
03:31Now, I don't know what my images are going to be because this is going to be
03:33coming in from dynamic data. So, I'm going to have a lot of placeholders here.
03:38I'm going to do source equals placeholder and then space and then alt equals
03:46placeholder. I'll tell you what. Code writing is nice, but sometimes it gets a
03:49headache, name is going to equal placeholder. So a lot of attributes here in
03:55this image tag and it's going to be doing a lot of different things for us,
03:58width is, like an equal placeholders, it can be 125 pixels, a lot of thumbnails
04:02are of the same size. So I'm going to do 125, height is going to be 135.
04:10Finally the id will also be placeholder because that is going to be dynamic as
04:16well. Now this image tag is a self- closing tag. So, I'm going to do a space, a
04:19forward slash and close that out and we'll save that. Now, only one? Well,
04:25remember we are going to dynamically build this widget. So, we'll have as many
04:27thumbnails as we have inside the XML file. So, instead of using four different
04:32link tags, we are just go ahead and let Spry populate that for us.
04:35Okay, so now we need to do our actual widget structure. The good news is that
04:39really the widget structure is extremely simple. So, I'm going to go down below
04:43my thumb region or on my thumbs div tag, and I'm going to open up another div
04:46tag and this is going to serve as my parent. So, I'm going to give this an id
04:50of panelContainer. Now I want to mention something here, this is not required
04:55by the Spry widget. I'm doing this simply because I want to be able to style
05:00this for the little bit more control. So I'm wrapping my entire widget in a div
05:04tag, that's going to give me a little extra styling up.
05:06Now after that I'm going to type in another div tag. So, inside that I'm going
05:09to nest another div tag. And this one is going to be the id of detailSlide1.
05:14Now, that could be anything, I wanted to be but that seems to make sense. And
05:21then the class is going to be SlidingPanels, now that cannot be anything I
05:27wanted it to be. But I wanted to just use the default widget structure that if
05:30the class that I have to give to me Sliding Panels. I'll go ahead and close
05:34that div tag out.
05:37Inside of that I'm going to open up yet another div tag. So, widgets are
05:41getting lots of div tags. And this one is going to have the class attribute of
05:45SlidingPanelsContentGroup. Pay attention to the capitalization because it does matter.
05:54So what this div tag does for us is all of the individual panels
05:57themselves, it helps to group them together. So this identifies the panel
06:01widget itself. This identifies the grouping of panels inside a widget.
06:05Now we are going to go down to the next line and we are going to do another div
06:09tag and this one is going to have an id. And I'm going to go ahead and set the
06:13initial id to panel0. We'll make that dynamic a little bit later on but for
06:17right now we are going to test the function, this is going to be panel0. Then
06:21its class attribute is going to be SlidingPanelsContent. We are going to go
06:27ahead and close that out, close that div tag.
06:31Now just a word about this for a moment. So inside your
06:33SlidingPanelsContentGroup, you are going to have the individual panels
06:37themselves, and this is the first one. So, for every panel I would want, I'll
06:40add another div tag. I'll change the id from 0 to 1 to 2 to 3. And I would
06:46still keep it with the same class, SlidingPanelsContent. Again you could
06:50manually build this up, we are going to dynamically populate this, so each one
06:54of theses would be in our Spry Repeat region.
06:56So, inside that I'm just going to add a little bit more structure. I'm going to
07:00do an h2 tag, and that's going to give me the Product Name, which is just
07:04placeholder data that we'll replace later ,and then finally- I'm very glad to
07:08hear that- let's do a paragraph and inside that I'm going to type in
07:11Description. Again that's just placeholder data and then type in a span tag and
07:17the span tag go ahead and give it a class of price. Notice that we already have
07:21a style for that. I'm going to type in the text, price, and then close the span
07:25tag, and close paragraph tag. So, that's going to allow us to have a
07:28description and a price in the same paragraph and of course all that will be
07:32replaced with dynamic data.
07:34So I'm going to go ahead and save my file. I know it's not much to look at, but
07:38all the proper structure is in place and it's ready for content now. Keep in mind
07:42that since our panels will be going to dynamically generated and
07:44populated, we only needed one thumbnail and one panel. Now with that external
07:48data in mind our next step is going to be to make the data available to us on
07:52the page by creating a Spry data set.
Collapse this transcript
Constructing Spry datasets through code
00:00Our Sliding Panel structure is in place, but we aren't able to populate it with
00:04data yet since we don't have a defined dataset. We'll take care of that now by
00:08linking to the necessary Spry Assets with the construction of an XML dataset
00:13and then using a constructor function to create the data self itself. This will
00:17require us to write a little JavaScript, but as we'll see it is fairly simple to do.
00:21Now the first thing I'm going to do is I'm going to put my head in the 06_03
00:24Spry Assets folder and I'm going to make sure we have got everything that we
00:27need. We need the SpryData.js, check. We got that and we also need the
00:33xpath.js, check. We have got that, okay. So, if I didn't have those I would
00:37need to go to the Spry Framework get them and copy them in here, so you always
00:40want to double check to make sure you have got the necessary Spry Assets before
00:44you link to them or add them to the page.
00:45So I'm just going to go over my Code view, scroll up to the very top of my code
00:53and here again I can see some existing script tags and link tags that are
00:56already bringing in some of those assets. So I'm going to go right below my
01:00script tags. I like grouping those together so that my script tags and my link
01:03tags are all grouped there together. So I'm going to type in script and I'm
01:08going to do src and if you want you can go ahead and browse for this.
01:12I am going to browse for this and I'm going to go in the Chapter 6, 06_03
01:18folder, SpryAssets and what we are looking for is the xpath.js. So you can see
01:25it just goes in and resolves that for us. Let's just go ahead and do type
01:31text/javascript, close that and then close the script tag. Here we go, save
01:38that and I notice the little error message I had up there is now missing. All
01:41right, fantastic.
01:42Well just below that we can see a constructor function that's building the HTML
01:46dataset and that is populating our prints that we did actually earlier in the
01:51title, so then it's still there. Well there is nothing wrong with having
01:54multiple datasets in a file. So right after the constructor function for this
01:58one, I'm going to go on another line and I'm going to type in var and then a
02:02space, and you want to do dsProducts. So notice it is a unique name. ds is the
02:08identifier as data source. It's just a nice name you can mention to use. = new
02:11and I'm going to do spry.data. And this time XML dataset.
02:20Inside I'm going to open up some parenthesis. Inside that with quotation marks,
02:23I'm going to type in _xml/specials. xml. Notice that it was giving me the
02:32opportunity to browse there and if I typed that in, well I'll be kicking myself
02:35that I didn't take it. When you are doing an XML dataset in addition to telling
02:40it where to find the XML file, you really need to use xpath notation to tell it
02:44which note you want to access is repeating root note. So what we are going to
02:47do now is I'm going to type in a comma, open up another set of quotation marks
02:53and I'm going to type in products. Remember that is our parent tag, forward
02:56slash item and that is the repeating element.
02:59So as long as you know the interior structure of your XML file that's going to
03:03be very easy to populate. Otherwise you definitely want to take a look at the
03:06schema before you come in here and do that. So we'll go ahead and save that and
03:11what's really kind of cool about this now is because we are using HTML and XML
03:15files, if I switch back to the Design view -- it doesn't really matter but I'm
03:18now going to open up my Bindings panel and if I refresh my Bindings, there is
03:23these dsProducts and if I open that guy up, I can see I have description,
03:27panel, price, thumb, id, index, name, all of those things that we were working
03:32on earlier are now available to us and we can place the data on the page
03:36anytime we want by using a combination of data regions and data references.
03:41Wonderful, now our structure is in place and our data is available. The next
03:45step will be to define the regions of our widget that will be displaying
03:48dynamic data, so that Spry can began to populate our widget.
Collapse this transcript
Defining Spry regions and data references
00:00In order for Spry to display data form your dataset, you will need two things.
00:04First you need to define a parent tag as a Spry region. This tells Spry that
00:09all the content inside of the parent tag is referencing a specific dataset or
00:13sets. Once that is taken care of, you populate the contents inside the parent
00:17tag using data references. A data reference is a simple textural reference that
00:22corresponds to the information from the dataset that you want to display.
00:25As you will see as we add our Spry regions, there are different types of Spry
00:29regions that help you control exactly how that data is displayed. To display
00:33more than one item from the dataset, we'll use a Spry Repeat Region. This will
00:38allow us to populate our widgets with all the datasets data and to repeat the
00:42structural elements contained within. This is how we'll end up with multiple
00:46div tags inside of our sliding panels widget instead of just the one.
00:49And I'm just going to switch right over to Code view and I'm going to scroll
00:53down till I find my widget structure. And don't be fooled, remember that we
00:56have that Spry region up there. I'm going to go down till about line 79 or so.
01:01Here we have a div with an id of thumbs. Here is our thumbRegion. This is all
01:05the stuff that we created earlier.
01:06So we need to take care of both of those, we have two Spry regions for this.
01:10I'll go to line 79, the div and id of thumbs then I'm going to go ahead and
01:15make that a Spry region. And notice that we have two datasets to choose from
01:21and now this time I'm going to use dsProducts. So code hinting is really
01:24helping us out here.
01:25Now the next thing I'm going to do is I'm going to go in and I want to have
01:28multiple images, remember. So we have our image and it is wrapped by a link
01:33tag. But the reason I did the span tag here is I want to have multiples of
01:37those so I can make this little span tag be a repeat region. So right after the
01:41id of the thumb region span tag, I'm going to do spry and then repeat, and it
01:47is going to repeat from the dsProducts as well.
01:50Now that we have our Spry regions for our thumb area, we need to go down into
01:54our Spry regions for our widget structure. So I'm going to go to where my div
01:59panelContainer is and I'm actually going to go ahead and do this to the
02:02SlidingPanels. So, it just needs to be one of the parent elements. I could have
02:05done to the panelContainer but since this is the actual widget itself, this is
02:09a tag that I created for styling purposes, I'm going to go ahead and do it to the widget.
02:13So after the class SlidingPanels, I'm going to do another Spry Region and it is
02:19going to be dsProducts as well and remember we'll need a Spry Repeat Region
02:24also. So I'm going to go into my SlidingPanelsContent. Now remember this is the
02:29div that it groups all of our panels together. These are the individual panels
02:33themselves. I need multiples of these and that is why that is going to get the
02:37Spry Repeat Region. So we'll do spry and then repeat and once again that is
02:43going to be dsProducts.
02:44So we have all of our Spry regions in place, but we don't have any of our data
02:47references in place. So, let's go back up and do that. This is going to require
02:51a little precision based on what we have got happening up on line number 81.
02:55This is our link tag surrounding our image tag.
02:57So I'm going to highlight title, right now that says placeholder and I'm going
03:02to replace that with {@name}. Now, look at that, because we have this dataset
03:08created, it knows that we are doing a data reference and it is going to go down
03:12and help us with code hinting. So this is going to be a lot easier than I
03:16thought. For src, I'm going to replace placeholder and I'm going to open up a
03:19curly brace and that is going to be thumb. So, I'll type in th and then thumb
03:24and it will fix it for me. My alt text is going to come from the name so that
03:29is going to be @name. The name itself strange enough is going to come from id
03:36and then id is also going to come from id.
03:40So that is going to take care of all our images. I'm going to go down now and
03:43take care of all the data references inside of our SlidingPanels. We don't have
03:48too many here. I'm going to replace Product Name with the name itself. And then
03:54I'm going to replace the Description with the description and price with price.
04:04There is one last little piece of house cleaning that we need to do here. Right
04:09after my SlidingPanels detail slide, I'm just going to do a little line break
04:14and I'm going to give that a class of clearfloat and that is going to handle a
04:19little bit of formatting issues that we might come up with. And that's based on
04:22our floated layout of the SlidingPanels that we are going to be doing a little
04:25bit later on. So just going to go ahead and doing a little house cleaning there.
04:28So I'm going to go ahead and save that. And I'm going to preview that in my
04:32browser, as I scroll down, there is all my products. There is all my
04:37thumbnails, they are repeating and there is each one of my descriptions and my titles.
04:43So we have a repeating structure that is being created through the use of our
04:46XML dataset, that's pretty cool. We are still not all the way there however. We
04:50still have to control our widgets functionality and modify it's styling.
04:53Although the styling is the fun part, we're going to control the basic functionality next.
Collapse this transcript
Constructing Spry widgets through code
00:00As we found when creating our XML Dataset, creating Spry objects through a code
00:04is fairly simple once you know the proper syntax. The usual process is to link
00:09to any external JavaScript and CSS files necessary for the object and then use a
00:14constructor function to create a new instance of your Spry object.
00:17Creating Spry widgets through code is no different and those are the exact
00:20steps that we'll use when creating our Sliding Panels widget and I'm just going
00:24to go ahead and switch over to Code view because if you remember from our
00:27previous exercise, our widget is populating with the data but there is no widget
00:32functionality. Well that's because up to this point, there really isn't a widget.
00:36So I'm going to scroll up to the very top of my code and here we are going to
00:40need to go ahead and initialize our widget. Now we are going to need to link to
00:42some of our external Spry Assets and if I open my 06_05 SpryAssets folder,
00:48I can see that I have already in there SlidingPanels.css and
00:53SprySlidingPanels.js.
00:54So again if I did not have those, I would have to copy them over from the Spry
00:58Framework. So I'm going to go again into my Source code and right here after
01:03about line 16, I'm going to go ahead and hit Return into this again, actually
01:07you know what, let's copy and paste. Why not? Why make life difficult for ourselves, right?
01:13So after I copy and paste the xpath.js, I'm going to change that so that this
01:17now says SprySlidingPanels.js. I also need a little new link tags, I'm going to
01:26highlight a link tag and copy that, paste it below the existing links and
01:31again, I'm going to change this to SprySlidingPanels.css and all the rest of
01:39that can stay the same.
01:40So that's going to link to the external assets the SprySlidingPanels.js and the
01:45SprySlidingPanels.css necessary to construct our widget. So I'm going to go
01:49ahead and save this and we still don't have a Sliding Panels widget though,
01:53just like the datasets that we created in the HTML and the XML dataset, you
01:58have to instantiate. So we are going to go into our constructor functions,
02:01right down here and make a new Spry Sliding Panels.
02:05We could do that at the top of our code but we have another set of objects
02:10being instantiated down here at the bottom of the code and that's going to help
02:13me separate my datasets from my actual widget objects. So I'm going to go right
02:17down here where our menu bar is being instantiated and we'll write another
02:21constructor function for our Sliding Panels, directly underneath that.
02:24So I'm going to go ahead and type in var on that blank line and this is going
02:28to be sp1. Now, we could give it any name that we want but that's what we can
02:33reference in code when we referencing our Sliding Panels. We did in sp1 equals
02:37new Spry.widget.SlidingPanels.
02:43This is going to require a couple of different parameters passed into it and
02:46here's what's really important to understand, how the constructor function for
02:50each widget works. This is fully covered within the online Spry documentation,
02:54so any widget that you want to create, you should be able to go online,
02:57de-construct, the constructor function and figure out exactly what it's looking
03:00for and even some options that you might not have known that you can place in there.
03:04But the first thing it wants to know which element on the page is the Sliding
03:08Panels widget. So in quotation marks I'm going to type in "detailSlide1". Now
03:16if you remember I'm going to scroll up just a little bit here, detailSlide1 is
03:20the div tag right there and this is our Sliding Panels widgets so it's just
03:24identifying which element we are telling it is our Sliding Panels widget.
03:28Then I'm going to type in a comma, we need to pass in several parameters for a
03:32Sliding Panels widget. So when you are passing any options for it, you do that
03:35within curly braces so we'll go ahead and send those on and as arrays, so we
03:39are going to type in duration:500, it's in milliseconds and what that is saying
03:44is that their panels are going to animate for half a second.
03:47Then I'm going to type in comma and I'm going to type fps and then colon and
03:53then 60, so that is frames per second and this is that going to help control
03:57our animation and we need to close the curly braces, close my parenthesis, and
04:01type in semi colon.
04:02So these two items that are here, are going to control our animation. This is
04:06how long it should animate and this is the qualitative animation frames per
04:09second. That's going to play at large factor into exactly how fast that
04:12animates and how good the quality is, more frames per second equals more
04:16quality but on slower connections, it really actually could result in less
04:20quality because the animation might start to jump a little bit. So you want to
04:23test that very thoroughly.
04:25Again these are options that we have learned about in the Spry online
04:28documentation, so any Spry object that you want to create through coding, you
04:32want to be very, very careful and read the documentation thoroughly, so you
04:34know exactly how to initialize that.
04:36So I'm going to go ahead and save that and for the first time we are going to
04:40preview our brand new Sliding Panels widget in our browser. So I'm going to
04:44scroll down and there is our Sliding Panels widget and if I click on one of
04:49these guys, check that out. It's going to go and animate that.
04:53So although not the style the way we need it to, our Sliding Panels widget is
04:56functioning properly, well almost. The animation is vertical instead of
05:00horizontal, the way we need it to be. So this illustrates another fundamental
05:03concept of using Spry, the JavaScript and CSS work together for appearance and
05:09functionality. Our remaining task will be to rewrite our CSS to help control
05:13both styling and functionality and we'll tackle the functionality of our CSS next.
Collapse this transcript
Controlling panel animation through CSS
00:00Our SlidingPanels widget is working, but it's not working exactly the way we
00:04would like. With many Spry widgets functionality can be modified by making
00:08quick changes to the default CSS.
00:10In the case of our SlidingPanels widget we'll modify the height to control the
00:14viewing area for our panel content and make our panels animate horizontally by
00:18floating them in a horizontal line and we'll control all of that through the
00:22CSS. And before we go and modify the CSS, I want to take just a moment to
00:27review the panel functionality.
00:28I am going to go into the Code view and I'm going to scroll down to my panel so
00:31that we can really see what's going on here between our thumbnail regions and
00:35the SlidingPanels widget and how these guys are communicating.
00:38So here we have spry:regions and we are repeating both the image and the
00:43SlidingPanels themselves. So inside of our link tag now we have a little bit of
00:47JavaScript going on here. We have onClick event and it is driving
00:51sp1.showPanel. sp1 if you remember correctly, this is the name of our
00:57SlidingPanels. And showPanel is the default method for our SlidingPanels, that
01:03tells the widget which panel to show as we are picking that up from our XML
01:07file. So @index is bringing in 0,1,2,3.
01:11So in addition to showing content through the use of our dynamic data, we are
01:15also now changing the functionality of our SlidingPanels widget through that
01:20dynamic data as well. So there is a lot of really cool stuff going on here. I
01:23want to pick through this code and get a good feel for exactly how the
01:27SlidingPanels widget is working.
01:29With that in mind, what we were going to do is we are going to stay in Code
01:31view and we are going to go to the SprySlidingPanels.css. So here we have again
01:37well-commented code out, telling us exactly what is going on with our
01:42SlidingPanels widget and what these styles are affecting.
01:45So the first one I want to go to is the very top one SlidingPanels. This is the
01:49parent tag style and it's styled the container div tag for our entire widget.
01:55Now the relative positioning, the width of 100%, all that is okay. But the
01:59height is the real problem here, at 400 pixels it's much to too tall for our
02:03content. So I'm going to shrink down to 210 pixels. Now I have just shrunk the
02:07amount of viewing area that we have for our SlidingPanels. So we are not going
02:11to see as tall of window area. We still have a padding of 0 pixels and a border of none.
02:16But I'm going to change one thing here. I'm going to come in and give it a
02:20float property and I'm going to float that left. And that's going to help us
02:25animate that horizontally and that's actually described up in the commenting
02:31features for our panel. So they tell you exactly how to get horizontal
02:35animation out of that.
02:36Now I'm going to go down to our SlidingPanelsContentGroup and I'm going to
02:40change the width from 100%, I'm going to change that to something really big,
02:44so I'm going to do 10,000 pixels. And you are probably like, do what? But trust
02:50me on this, you see since we are going to float each one of those panels they
02:54have to be wide enough so that all of them can stack in a row. If I was going
02:58to have 6, 7, 8, 9, 10 panels, I would make it even wider than that. I want to
03:03make sure that they are all going to able to float right beside each other.
03:06Now the next thing I'm going to do is right after border I'm going to come down
03:09and I'm going to tell those guys to float to the left as well. That's going to
03:12stack them at a nice horizontal row.
03:14Now the last thing we need to do is go down and style the SlidingPanelsContent.
03:19Now these are the actual panels themselves, remember they are contained within
03:24the group. So now what we are going to do with these guys is we are going to
03:26change their width to 700 pixels, that's going to be the content area that they
03:32can display in. And that width is based on the wrapper width themselves.
03:36The height is going to be 210 pixels. Again remember that is referencing the
03:40height that we have in the SlidingPanels widget itself. So we are making them
03:45exactly as tall. So we have margin of 0 and a padding of 0. And once again we
03:49are going to float these guys to the left. What that's going to accomplished
03:53for us is it's going to align them up all in a single horizontal row.
03:57The last thing we are going to do, so we are going to go ahead and give them a
03:59background color. And I'm going to type in #A8BAAA and that's going to give
04:06each one of our SlidingPanels their own little background color. So we are
04:11going to do a Save All and let's preview that in our browser to see how that
04:15has affected our functionality.
04:17If I scroll down, I can see that now my SlidingPanels are all in a straight
04:21line. And if I click on those guys you can see now they are animating
04:24horizontally rather than vertically. Awesome! So we are almost there.
04:29Now you may have noticed we don't have any larger images for items displaying.
04:33So that's something we want to take care of. And also one of the benefits of
04:36using Spry is the openness and flexibility that we have when modifying and
04:40customizing our Spry content. And we are going to take advantage of that by
04:43adding the product images to our panels, customize our styling when the panels
04:47are animating to look like the content is blurring. And that is what we'll take
04:50care of next.
Collapse this transcript
Enhancing effects through CSS
00:00By now, I hope you've gotten the idea that the default styling and
00:03functionality of Spry widgets is merely the starting point. What you with you
00:07widgets and how you customize them is totally up to you.
00:11In this example, I'd love to enhance the effect of the panel animation by
00:14blurring my images as they animate. In researching the Sliding Panel widget,
00:19I discovered that Spry dynamically assigns the calls Sliding Panels animating to
00:24the panels when they are animating and then removes it when they are finished.
00:28Once I had that, tweaking the styling was as easy as creating the blurred
00:31version of the product images and writing a few new selectors. We'll add our
00:35images as background images first, and then create our animated styles.
00:39I am just going to go ahead switch over to Code view and look at the source
00:44code, and if I scroll up towards the top, I can see that some embedded styles
00:47have been added that are helping the format, the content of my Sliding Panels .
00:52So we are going to add some new styles to this section.
00:54Now the first thing I'm going to do is I'm going to copy this commenting line
00:58and then paste it just below the existing group of styles. I always like to
01:02separate my styles in sections and this really helps with that. So I'm going to
01:06type in background images for panels, because that is what we are going to be doing next.
01:12Now the first thing we are going to do is we are going to target each panel,
01:15and as a way of refreshing my memory, we know that each penal has a specific
01:19number, panel0, panel1, panel2, and panel3. Those are being assigned
01:24dynamically, but it's still an id and we can still write styles for it. So
01:28classes and ids that are assigned dynamically, you an still write selectors for them,
01:32and when that class or ID association is made, you will see the formatting.
01:36So I'm going to type in #main content, so we are staying fairly specific with
01:40these, #panel0, all one word, no spaces, and then I'm going to go ahead and
01:46open up my curly bracket and I'm going to type in background#a8baaa and then a
01:54space, and we are going to give a background image, so I'm going to type in URL
01:58images\details. We have a subdirectory called Details \hoody_details.jpg.
02:09For positioning, we'll type in no repeat, so that it doesn't tile. Then we'll
02:13type in 10 pixels for horizontal and 5 pixels for vertical, and that's just to
02:18shift it around a little bit inside the Sliding Panels.
02:21Now as you can imagine, each of the panels is extremely similar, the only thing
02:24that really changes is the image itself. So I'm going to copy this and then
02:30paste it once, twice, and then a third time. First thing I'll do is I'll change
02:35the panel numbers. So panel 1, 2, and 3. Now have got selectors for each of my
02:41panels that are being dynamically assigned, and now I just have to go and I
02:44have change the graphic.
02:45Now all of them are named the same thing. They have the name of the item and
02:49then _detail, so really all we have to change is that word for each of these guys.
02:54So the first one will be tshirt_ detail, then the third one is going to be
03:00bag_detail, and then the last one will be longt_detail. So it should be
03:07hoody_details, tshirt_detail, bag_ detail, and longt_detail. So I'll go ahead
03:15and save that, preview that in my browser, and we'll see we have our background images.
03:19Now we do.
03:20There are larger product images and those are coming in based upon the dynamic
03:26id association for the Sliding Panels. So that style is responding to what's
03:30coming out of the dataset. Very nice!
03:32Now we want to write our styles for when our panels are animating. So once
03:36again, I'm going to copy that comment line and paste it, and I'm going to
03:40replace the comment line with styles for panels as they animate. I'm trying to
03:47be as descriptive as I can.
03:50Now first we'll take care of the heading and the paragraph and the price. It's
03:54one thing to blur the images, but I'd also like the text style like it was
03:57blurring as well, and I can fake that a little bit by giving them sort of a
04:01light gray color, so that when it does animate, they will tend to dim out and
04:05get a little gray and it will give the illusion of them blurring.
04:09So we are going to type in #main content, now here's where we take advantage of
04:14the dynamic class association. SlidingPanelsAnimating, and you really have to
04:24remember what that is. If you are wondering where I found that. If I look over
04:29in the SprySlidingPanels.css, all the way towards the bottom, you can see right
04:34there SlidingPanelsAnimating, and currently the only thing that it's doing is
04:39everything inside of that is being hidden, if there is an overflow. That way,
04:42as they animate, if the dimensions change a little bit, you won't see scroll
04:46bars, so that's kind of nice.
04:47But we are using it for something entirely different, we are using it purely
04:51for decorative purposes. So #main content SlidingPanelsAnimating h2, so we'll
04:57first tackle the heading 2. We are going to go ahead and give it a color, and
05:00we are going to change its color to #999, that's the gray color obviously.
05:05We'll close our curly brace there, and again I'm a big believer in not typing
05:09things twice if you don't have to. So I'm going to copy and paste that, and I'm
05:13going to change the Heading 2 to p. it's going to get the same exact color,
05:17just copy and paste, and this time we are going to change the H2 to a
05:21span.price. If you remember, the prices inside of a span tag with a class of
05:27prices that's going to change all of those to that gray color.
05:30Again, we can save that, preview that in our browser, and as they animate,
05:35watch the text and as it dims out and all becomes gray. So it gives the
05:42illusion of blurring out and when we put our blurred images in there, it will
05:47enhance that effect.
05:48All right. So let's go back in our code and we are ready to go ahead and do our
05:52panels. Now I'm going to go ahead and paste that selector again, but this time
05:56I'm going to change H2 to #panel0. So again, we are taking advantage of that
06:02dynamic association.
06:04We are really not changing too much other than the background graphic, so I'm
06:08going to go right up here, and I'm going to steal some stuff from up here. I'm
06:11going to go ahead and grab the background of my main content panel0, copy that,
06:17and then I'll replace the color that's in there with that. Instead of
06:21hoody_detail, let's make this as easy as possible. I make sure I name them just
06:26hoody_blur. So I have a detailed image and I have a blurred image.
06:30So in reality, I can now just copy this, paste it once, twice, three times,
06:39change my ids again, panel1, panel2, and panel3, just what we did above, and
06:44now instead of hoody_blur, I'm once again going to highlight these and type in
06:49tshirt_blur, bag_blur, and finally longt_blur.
06:59The other thing that copying and pasting does to you, if you test it and make
07:02sure that it works, then that sort of prevents worrying too much about having a
07:06typo and misspelling something, very easy to do when you have these long class names.
07:10So I'm going to go ahead and save that again, we are going to preview this on
07:13our browser, and as I scroll down, now it animates, blurred version comes in,
07:20and you can see how it really enhances the effect, but having the text be gray
07:23as well. So it's working perfectly.
07:26So we have a fully functioning, customized Sliding Panels widget, all carefully
07:30constructed by hand. Far from being intimidating, Spry offers a wonderful
07:34opportunity for designers to work within the confines of technologies that they
07:38are already comfortable with, such as XHTML and CSS, and it used that
07:42technology to control complex AJAX driven elements, all of this without having
07:47to do hardly any JavaScript at all. Well, not only actually if you let
07:49Dreamweaver add the code for you.
07:51I hope you have enjoyed this introduction to Spry and that you will use it as a
07:54starting point to learn more about what this amazing framework can do for your own sites.
Collapse this transcript
Conclusion
Goodbye
00:00I hope you have enjoyed Dreamweaver CS4 Introduction to Spry. Although we have
00:04more than scratched the surface of using Dreamweaver and Spry, I hope that
00:08this title will merely serve as a starting point in your journey of building
00:12AJAX driven sites with Spry and Dreamweaver.
Collapse this transcript


Suggested courses to watch next:

Dreamweaver CS5.5 New Features (1h 50m)
James Williamson



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 100,877 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,943 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