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 menuInsert > 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 Objects/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 obviously linked to objects: Tabular Data.htm, Jump Menu.htm, LayoutCell.htm, LayoutTable.htm, Navigation Bar.htm, and Date.htm.

Coloring Outside the Lines

You might want to mix the functionality of extension types for similar reasons. When you were reading through Chapter 3, "Creating Custom Behaviors," for instance, were you struck by how many JavaScripts you couldn't turn into behaviors because they didn't fit the mold of generic function/function call? If you created a command that inserted the proper JavaScript code instead of a behavior, you could overcome those limitationsbut for intuitive interface presentation, you still might want the command to show up in the Behaviors panel's actions list. The moral of the story is to never feel limited by extension types. Determine the best way to create the result you wantinsert code, manipulate code, whateverand then determine how you can mix and match extension types to make this work intuitively for your users.



Dreamweaver MX Extensions
Dreamweaver MX Extensions
ISBN: 0735711828
EAN: 2147483647
Year: 2001
Pages: 141
Authors: Laura Gutman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net