Share this Page URL
Help

Part II: Commands, Inspectors, Floating ... > Mixing Extension Types - Pg. 236

236 Chapter 8. Mixing Extension Types If you have worked through all seven preceding chapters, you should now have a good under- standing of the major extension types, what each requires, and what sort of tasks each is best at. In this chapter, we'll see how to go beyond the restrictions of individual extension types to access the functionality of one extension type from within the structure of another. Menu commands and floaters can insert objects and behaviors, object files can run commands, and so forth. All of this is possible within the Dreamweaver Application Programming Interface (API). Why Mix Extension Types? Why would we want to mix extension types? There are all sorts of reasons, but they break down into considerations of interface usability versus extension functionality. Rollovers, Jump Menus, and Navigation Bars, Oh My! Sometimes the "correct" way to code an extension isn't the most logical one for the user. For instance, users intuitively expect items that insert things into documents to be part of the Insert bar and Insert menu--Insert > Table, Insert > Image, Insert > Flash, and so forth. But not all insertion tasks are as easy as that. When a user chooses the Insert Rollover object, for instance, what's happening? Dreamweaver is inserting the code for a linked image into the document at the insertion point, but the program is also inserting a Swap Image function in the head of the document and the relevant function call in the body. Those tasks can't all be performed by the lowly objectTag() function. The Rollover "object" should really be an object plus a behavior, or maybe some of each combined into a command. Take a look at the files behind Insert Rollover, and you'll see the following happening: · The Insert Rollover object file (Rollover.htm in Objects/Common) contains no <body> content at all to generate the dialog box you see when this object is activated. · The objectTag() function found in the object file's linked JavaScript file (Rollover.js in Ob- jects/Common) calls a command file called Rollover.htm to create the content it will insert into the user's document. · The related command file (Rollover.htm in Commands) contains the <form> that will become the dialog box. · The command file's linked JavaScript file (Rollover.js in Commands) is what actually builds the rollover code. In other words, you have an object file that calls on a command file to help it perform its function. If you examine the contents of the Commands file, you'll recognize several other files that are ob- viously linked to objects: Tabular Data.htm, Jump Menu.htm, LayoutCell.htm, LayoutTable.htm, Navigation Bar.htm, and Date.htm.