background image

Extending Dreamweaver

Summary of Contents for DREAMWEAVER 8-EXTENDING DREAMWEAVER

Page 1: ...Extending Dreamweaver...

Page 2: ...y responsibility for the content on those third party sites Opera browser Copyright 1995 2002 Opera Software ASA and its suppliers All rights reserved Copyright 2005 Macromedia Inc All rights reserved...

Page 3: ...zing Dreamweaver in a multiuser environment 27 Working with browser profiles 30 Changing FTP mappings 34 Extensible document types in Dreamweaver 35 Chapter 2 Customizing Code View 55 Code hints 55 Co...

Page 4: ...n file 141 Modifying the Insert bar 148 A simple insert object example 150 The Objects API 161 Chapter 7 Commands 167 How commands work 167 Adding commands to the Commands menu 168 A simple command ex...

Page 5: ...y inspector API 285 Chapter 13 Floating Panels 289 How floating panel files work 290 A simple floating panel example 291 The Floating panel API 297 Chapter 14 Behaviors 305 How Behaviors work 306 A si...

Page 6: ...erver Model API functions 424 Chapter 20 Data Translators 433 How data translators work 434 Determining what kind of translator to use 435 Adding a translated attribute to a tag 435 Inspecting transla...

Page 7: ...Contents 7 PART 4 APPENDIX Appendix The Shared Folder 483 The Shared folder contents 483 Using the Shared folder 491 Index 493...

Page 8: ...8 Contents...

Page 9: ...se functions and also the values that Dreamweaver expects these functions to return For information on the utility and general purpose JavaScript APIs that you can use to perform various support opera...

Page 10: ...Manage Extensions to start the Extension Manager The Extension Manager automatically installs the extension from the Downloaded Extension folder into Dreamweaver Some extensions need Dreamweaver to re...

Page 11: ...nterfaces that are extensible Each of these features has new related functions which are listed in the Dreamweaver API Reference Improved site synchronization The comparison of local and remote files...

Page 12: ...ted New and updated examples New examples have been added for Reports and Behaviors The example for Property inspectors has been improved The steps for creating each type of extension are presented as...

Page 13: ...two or more lines Due to margin limits in this guide s format what is otherwise a continuous line of code must be split When copying the lines of code eliminate the continuation symbol and type the l...

Page 14: ...14 Introduction...

Page 15: ...changing settings in dialog boxes setting preferences in a variety of areas and changing keyboard shortcuts You can also customize code hints and code coloring in Code view the cascading style sheet C...

Page 16: ......

Page 17: ...shortcuts using the Keyboard Shortcut Editor Edit Keyboard Shortcuts The following list describes some of the ways you can customize Dreamweaver by editing configuration files Rearrange the objects i...

Page 18: ...esets and page designs You can create pages based on these designs by selecting File New To customize the available designs edit the files in BuiltIn css BuiltIn framesets BuiltIn Templates and BuiltI...

Page 19: ...the Configuration folder in place of the original It s a good idea to first make a backup of the original so you can restore it later if needed 9 Restart Dreamweaver to see the changes You should chan...

Page 20: ...the file 5 Restart Dreamweaver To see the new default select File Open and look at the pop up menu of file types To add new file types to the menu in the File Open dialog box 1 Make a backup copy of t...

Page 21: ...ntent model rendering scheme and icon for one or more custom tags You can create any number of tag database files but all of them must reside in the Configuration ThirdPartyTags folder to be read and...

Page 22: ...For string delimited tags tag_name is used only to determine whether a given Property inspector can be used for the tag If the first line of the Property inspector contains this tag name with an aste...

Page 23: ...cument so you can t place a marker_model tag that contains plain text in the head section To place a custom tag containing plain text in the head section specify the tag s content model as head_model...

Page 24: ...quired for empty tags and for nonempty tags whose contents do not appear in the Document window s Design view icon_width specifies the width of the icon in pixels icon_height specifies the height of t...

Page 25: ...f the code happy code tag happy Joe happy p Because render_contents is set to false in the tag specification the contents of the happy tag the word Joe are not rendered Instead the start and end tags...

Page 26: ...he Dreamweaver encoding behavior when you re working with files that contain third party tags To allow Dreamweaver to rewrite HTML in more kinds of files 1 Select Edit Preferences and select the Code...

Page 27: ...ead of modifying the Dreamweaver Configuration files To customize Dreamweaver by editing a configuration file in a multiuser environment edit the appropriate user Configuration file rather than editin...

Page 28: ...r to the corresponding location inside your user Configuration folder Then edit the copy in your user Configuration folder Deleting configuration files in a multiuser environment When working in a mul...

Page 29: ...tribute lists with curly braces all attributes not marked with curly braces are required deleteditems Description Container tag that holds a list of items that Dreamweaver should treat as deleted Attr...

Page 30: ...rnings error messages and suggestions for tag substitutions Browser profiles are stored in the Configuration BrowserProfiles folder in the Dreamweaver application folder You can edit existing profiles...

Page 31: ...ttribute of the htmlTag tag is not supported Try using supportedAttribute1 for a similar effect supportedAttribute1 supportedAttribute2 validValue1 validValue2 validValue3 unsupportedAttribute2 Error...

Page 32: ...r a future version of Microsoft Internet Explorer you can open the profile for the most recent version of Internet Explorer that has a profile add any new tags or attributes introduced in the new vers...

Page 33: ...r because browsers rarely drop support for tags 5 Add any custom error messages according to the syntax shown in About browser profile formatting on page 30 The profiles that come with Dreamweaver lis...

Page 34: ...tension Dreamweaver uses the BINARY transfer mode The following example shows a line from the Macintosh file that indicates that files with the extension html should be transferred in ASCII mode HTML...

Page 35: ...s information about at least one document type For each document type essential information such as server model color coding style descriptions and so forth is described Dreamweaver provides an initi...

Page 36: ...VBScript Template DWTemplate aspvb dwt ColdFusion Template DWTemplate cfm dwt HTML Template DWTemplate dwt JSP Template DWTemplate jsp dwt PHP Template DWTemplate php dwt HTML HTML htm html ActionScri...

Page 37: ...sp htm html macfileextension asp html previewfile default_aspjs_preview htm file default_aspjs htm priorversionservermodel UD4 ASP JS title loadString id mmdocumenttypes_0title title description loadS...

Page 38: ...all document type definition files servermodel No Specifies the associated server model case sensitive by default the following values are valid ASP NET C ASP NET VB ASP VBScript ASP JavaScript ColdF...

Page 39: ...types should map to Dynamic HTML should map to HTML Script files such as CSS JS VB and CS should map to Text If internaltype is DWTemplate you should also specify dynamicid If you omit dynamicid in t...

Page 40: ...ons by using a comma separated list The first extension in the list is the extension that Dreamweaver uses when the user saves a documenttype document If two nonserver model associated document types...

Page 41: ...the New Document dialog box You can place this string directly in the definition file or point to it indirectly for localization purposes For more information on localizing this string see Localized...

Page 42: ...on this PHP_MySQL dynamic document type documenttype id DWTemplate_PHP internaltype DWTemplate dynamicid PHP_MySQL winfileextension php dwt macfileextension php dwt file Default php dwt title PHP Temp...

Page 43: ...Dreamweaver 8 Configuration If Dreamweaver cannot find the Extensions txt file in the user s Configuration folder Dreamweaver looks for it in the Dreamweaver Configuration folder To create a new docum...

Page 44: ...f file types Localized strings Within a document type definition file the title and description subtags specify the display title and description for the document type You can use the MMString loadstr...

Page 45: ...server model share file extensions For example ASP JS and ASP VB can claim asp as their file extension For information on which server model gets preference see canRecognizeDocument on page 424 Dream...

Page 46: ...e server model returns the highest integer is the document type that Dreamweaver assigns to the document being opened If however more than one server model returns the same integer Dreamweaver goes th...

Page 47: ...ion Specifies the application window s initial position and size Attributes rect maximize rect specifies the position and size of the application window The string is in the form left top right bottom...

Page 48: ...e Contents None Container This tag must be contained in a panelset tag Example panelset document rect 100 257 1043 1200 maximize false document panelset panelframe Description Describes an entire pane...

Page 49: ...roup is used dock is a string value that specifies to which edge of the application frame to dock the panel group This attribute is ignored on the Macintosh because panel groups cannot be docked colla...

Page 50: ...icates the position and size of the panel when it is maximized The string is in the form left top right bottom specified as integers tabsinheader is a Boolean value true indicates that tabs should be...

Page 51: ...and the panel should be visible false otherwise Contents None Product ID Panel Flash 1 Properties 2 Actions 3 Align 4 Behaviors 5 Components 6 Component Inspector 7 Color Mixer 8 Color Swatches 9 Hist...

Page 52: ...the toolbar through the Extension Manager To change the order of button 1 Open the file Configuration Toolbars toolbars xml 2 Locate the Code view toolbar section by searching for the following comme...

Page 53: ...Focus true html command if dw getFocus true textView dw getFocus true html dw getDocumentDOM source expandAllCodeFragments update onViewChange 4 Save the file To make any buttons that are not visible...

Page 54: ...54 Customizing Dreamweaver...

Page 55: ...ow to customize these features Code hints Code hints are menus that Dreamweaver opens when you type certain character patterns in the Code view Code hints offer a typing shortcut by providing a list o...

Page 56: ...s of Code Hints menus Tag Names Attribute Names Attribute Values Function Arguments Object Methods and Variables and HTML Entities The description for each menu group The description appears in the Pr...

Page 57: ...e id CodeHints_Function_Arguments description description function pattern ArraySort array sort_type sort_order doctypes CFML function pattern Response addCookie Cookie cookie doctypes JSP menugroup c...

Page 58: ...enu group that is enabled appears with a check mark next to it in the Code Hints category of the Preferences dialog box Assign a true value to enable the menu group or a false value to disable a menu...

Page 59: ...f typed characters that cause Dreamweaver to open the Code Hints menu If the first character of the pattern is a letter number or underscore Dreamweaver displays the menu only if the character that pr...

Page 60: ...menu pattern CGI doctypes ColdFusion menuitem Description This tag specifies the text for an item in a Code Hints pop up menu The menuitem tag also specifies the value to insert into the text when you...

Page 61: ...ying function arguments and object methods for a Code Hints pop up menu When you type a function or method name in Code view Dreamweaver opens a menu of function prototypes displaying the current argu...

Page 62: ...ypes attribute as a comma separated list of document type IDs For a list of Dreamweaver document types see the Dreamweaver Configuration Documenttypes MMDocumentTypes xml file The casesensitive attrib...

Page 63: ...oloring files Dreamweaver defines code coloring styles and schemes in XML files that reside in the Configuration CodeColoring folder A code coloring style file defines styles for fields that are defin...

Page 64: ...ity 1 ignoreTags Yes ignoreTags defaultText name Text id CodeColor_TextText sampleText doctypes Text CDATA Default file syntax highlighting The quick brown fox jumped over the lazy dog sampleText sche...

Page 65: ...ority that lets you nest a block of text with one scheme inside a block of text with a different scheme Attributes name id priority doctypes name scheme_name A string that assigns a name to the scheme...

Page 66: ...red and the combination must be unique Values are not evaluated as case sensitive The blockEnd value can be one character Multiple instances of this tag are allowed For more information on blockEnd st...

Page 67: ...item name display_name A string that appears in the Edit Coloring Scheme dialog box when scheme customText scheme Required This defines how the blockStart and blockEnd strings are colored For informa...

Page 68: ...e delimiter of the end of a character You must specify the charStart and charEnd tags in pairs Multiple charStart charEnd pairs are allowed Attributes None Example charEnd CDATA charEnd charEsc Descri...

Page 69: ...TA commentEnd cssImport Description An empty tag that indicates the code coloring rule for the import function of the style element in a CSS Attributes name id name cssImport_name A string that assign...

Page 70: ...Property_name A string that assigns a name to the CSS property id id_string Required An identifier string that maps color and style to this syntax item Code Color Preference CSS Property Example cssPr...

Page 71: ...syntax that is where ignoreTags No If this tag is present then all tag attributes are colored according to the style assigned to this tag If this tag is omitted then attributes are colored the same a...

Page 72: ...name to the CSS Selector id id_string Required An identifier string that maps color and style to this syntax item Example defaultText name Text id CodeColor_TextText endOfLineComment Description A tex...

Page 73: ...eyword_name A string that assigns a name to the functionKeyword block id id_string Required An identifier string that maps color and style to this syntax item Example functionKeyword name Function Key...

Page 74: ...mple idCharRest name Identifier id CodeColor_JavascriptIdentifier _ abcdefghijklmnopqrstuvwxyzABCDEFGH IJKLMNOPQRSTUVWXYZ0123456789 idCharRest ignoreCase Description Specifies whether case should be i...

Page 75: ...s isLocked Description Specifies whether the text that is matched by this scheme is locked from being edited in the Code view Values are Yes and No Default is No Attributes None Example isLocked Yes i...

Page 76: ...d Example keywords name Reserved Keywords id CodeColor_JavascriptReserved keyword break keyword keyword case keyword keywords numbers Description An empty tag that specifies numbers that should be rec...

Page 77: ...tring Required An identifier string that maps color and style to this syntax item delimiter The character or string that starts and ends a regular expression escape The character or string that signal...

Page 78: ...ello world displayWords tokens sampleText searchPattern Description A string of characters that define a regular search pattern using supported wildcard characters Multiple searchPattern tags are allo...

Page 79: ...le stringStart name Attribute Value id CodeColor_HTMLString CDATA stringStart stringEnd Description Contains a text string that represents the delimiter of the end of a code string You must specify th...

Page 80: ...agLibrary_html tags table tbody td tfoot th thead tr vspec colw hspec Scheme block delimiter coloring The blockStart scheme attribute controls the coloring of block opening and closing strings or bloc...

Page 81: ...tomText value php if loginMsg echo loginMsg Example blockStart name Block Delimiter id CodeColor_JavaBlock doctypes JSP scheme customText CDATA blockStart outerTag The outerTag value specifies that bo...

Page 82: ...embedded inside other tags such as the cfoutput tag Sample code input type text name zip cfif newRecord IS no cfoutput query employee Value zip cfoutput cfif Example blockStart doctypes ColdFusion CF...

Page 83: ...indicates which fields are subject to code coloring in each mode To make the process of defining schemes more flexible Dreamweaver lets you specify wildcard and escape characters Field CSS Tags Scrip...

Page 84: ...t regular expression that starts and ends with a forward slash and can contain forward slashes that are preceded by a backslash Because the backslash is the code coloring escape character you must pre...

Page 85: ...s long plus a wildcard string for the name BeginEditable This leaves an editable region name that can be as man y as 74 characters which is the maximum of 100 characters minus 26 Escape character Esca...

Page 86: ...scheme If the priority is equal the scheme can nest only in the body state of the outer scheme For example the script script block can nest only inside the html html block where tags are legal not ins...

Page 87: ...ngStart specify color and style settings only on the first tag Data will be lost when you split color and style settings across tags and you later edit the colors or styles by using the Preferences di...

Page 88: ...in the XML file The value of the scheme name attribute precedes each field listed in the Styles For pane Fields that do not have a name are not listed The style for a particular element includes bold...

Page 89: ...t doctypes ASP JS ASP VB ASP NET_CSharp ASP NET_VB ColdFusion CFC HTML JSP LibraryItem DWTempl ate PHP_MySQL scheme outerTag CDATA style s blockStart blockEnd CDATA style blockEnd commentStart name Co...

Page 90: ...L scheme outerTag CDATA script blockStart blockEnd CDATA script blockEnd blockStart doctypes ASP JS ASP VB ASP NET_CSharp ASP NET_VB ColdFusion CFC HTML JSP LibraryItem DWTempl ate PHP_MySQL scheme ou...

Page 91: ...id CodeColor_JavascriptNative keyword abs keyword keywords keywords id CodeColor_JavascriptNumber keyword Infinity keyword keyword Nan keyword keywords keywords name Client Keywords id CodeColor_Javas...

Page 92: ...e user selected Dreamweaver underlines errors with a wavy red line Dreamweaver stores browser profiles in the Browser Profile folder inside the Dreamweaver Configuration folder Each browser profile is...

Page 93: ...or example the following names attribute is a shorthand method of defining the name attribute that follows it property names foo bar value type named name top value type named name bottom property pro...

Page 94: ...h for this item The units value matches a numeric value followed by one of the units values specified in the names attribute name value_name A CSS value identifier No spaces or punctuation allowed oth...

Page 95: ...the Preferences dialog box To change the format of specific tags and attributes use the Tag Library Editor Edit Tag Libraries For more information see Using Dreamweaver on the Dreamweaver Help menu Yo...

Page 96: ...96 Customizing Code View...

Page 97: ...to suit your web development needs These fundamental concepts include the Dreamweaver folders extension APIs Dreamweaver interface components the Dreamweaver Document Object Model DOM and Dreamweaver...

Page 98: ......

Page 99: ...tensive set of tools that you can use to add to or customize its functionality When you create a Dreamweaver extension you should follow the steps outlined in Creating an extension on page 10 The foll...

Page 100: ...tten reports that come with Dreamweaver You can also use the Results Window API to create a stand alone report Tag Library and Editor extensions work with the associated tag library files Tag Library...

Page 101: ...er supports the most common server models ASP JSP ColdFusion PHP and ASP NET Server model extensions are needed only for custom server solutions different languages or a customized server Server model...

Page 102: ...Menu Commands on page 181 Configuration folders and extensions The folders and files that are stored in the Dreamweaver Configuration folder contain the extensions that come with Dreamweaver When you...

Page 103: ...pt techniques and as utilities Look here first for the functions that perform specific tasks such as creating a valid Document Object Model DOM reference to an object testing whether the current selec...

Page 104: ...e ThirdPartyTags folder and before any other commands objects behaviors inspectors floating panels or translators You can use startup commands to modify the menus xml file or other extension files You...

Page 105: ...create dynamic link libraries DLLs The functionality that is provided in these APIs wraps your C DLLs in JavaScript so that your extension can work seamlessly in Dreamweaver The documentation of exte...

Page 106: ...action from a menu for the Command and Behavior action extension types Dreamweaver executes code in the onLoad event handler on the BODY tag if the body of the document contains a form for object ext...

Page 107: ...lays Help You can call the dreamweaver browseDocument function to open a file in a browser or devise a custom way to display Help such as displaying messages in another layer in alert boxes The follow...

Page 108: ...xample shows the format of the file strings errors for feature X string id featureX subProblemY value There was a with X when you did Y Try not to do Y string id featureX subProblemZ value There was a...

Page 109: ...following example shows how the string along with any variables to embed is passed to the alert function if fileMissing alert errMsg dw loadString featureX fileNotFoundInFolder fileName folderName Wo...

Page 110: ...110 Extending Dreamweaver...

Page 111: ...ions Some steps in the task can change or specific attributes of the code that the extension processes can change To receive user inputs for these variable values you build a UI For example you might...

Page 112: ...mes to the fields In a typical scenario after you create the UI you test the extension code to see that it properly performs the following UI related tasks Getting the values from the text boxes Setti...

Page 113: ...show the Base Property inspector without the DOCTYPE statement which improves form control rendering and then with the DOCTYPE statement The Base Property inspector as it appears in Design view witho...

Page 114: ...e which indicates that the select list is not editable As with standard noneditable select lists editable select lists have a selectedIndex property see Objects properties and methods of the Dreamweav...

Page 115: ...on getAlert var i document myForm mySelect selectedIndex if i 0 alert Selected index i n Selected text document myForm mySelect options i text else alert Nothing is selected n or you entered a value f...

Page 116: ...ctTest When you select a value from the list an alert message displays the index of the value and the text If you enter a value an alert message indicates that nothing is selected Database controls Us...

Page 117: ...able grid control Adding a database tree control The database tree control has the following attributes Attribute name Description name Name of the database tree control control style Width and height...

Page 118: ...ollowing attributes The following example adds a simple variable grid control to a dialog box select name ParamList style width 515px type mmparameterlist columns Name SQL Data Type Direction Default...

Page 119: ...is example creates two blank columns that are 182 pixels wide The specified columns total 136 The total width of the variable grid control is 500 The remaining space after the first three columns are...

Page 120: ...ontrol on page 117 no association with a database is required The Dreamweaver Keyboard Shortcuts editor uses the tree control as shown in the following figure Creating a tree control The MM TREECONTRO...

Page 121: ...s theControl Optional If the number of nodes in the theControl attribute exceeds the value of the size attribute scrollbars appear multiple Optional Allows multiple selections default is single select...

Page 122: ...in the same way as any other document node For more information on DOM functions and methods see Chapter 5 The Dreamweaver Document Object Model on page 127 Adding nodes To add a node to an existing...

Page 123: ...ted node from the document structure use the innerHTML or outerHTML properties The following example deletes the entire selected node and any children var tree document myTreeControl var selNode tree...

Page 124: ...u build extensions that use Flash forms animations ActionScript or other Flash content Basically you leverage the ability for Dreamweaver objects and commands to display dialogs see Chapter 6 Insert B...

Page 125: ...orm tag Then within the form tags use the Insert Media Flash menu option to add your Flash content to the Command definition file When prompted select the SWF file in the Commands folder and click OK...

Page 126: ...example shows a simple implementation of Dreamweaver s Flash content support After you are familiar with building objects and commands as well as more sophisticated forms you can integrate Flash conte...

Page 127: ...so on block level elements P DIV FORM and so on text level elements FONT BR IMG and so on and other element types Leaves on these offshoots include attributes such as WIDTH HEIGHT ALT and others In a...

Page 128: ...object For example to refer to the first image in the active document you can write dw getDocumentDOM images 0 You can also store the document object in a variable and use that variable in future refe...

Page 129: ...dth innerHeight screenX screenY alert confirm escape unescape close setTimeout clearTimeout setInterval clearInterval resizeTo onResize navigator platform None None document forms an array of form obj...

Page 130: ...tton reset submit In addition to the properties that are available for all tags form In addition to the methods that are available for all tags blur focus onClick checkbox radio In addition to the pro...

Page 131: ...or all tags name value None onChange array boolean date function math number object string regexp Matches Netscape Navigator 4 0 Matches Netscape Navigator 4 0 None text nodeType parentNode childNodes...

Page 132: ...st body The JavaScript object that corresponds to the BODY tag This property is shorthand for calling document documentElement childNodes and extracting the BODY tag from the NodeList For frameset doc...

Page 133: ...rHTML The source code for this tag including the tag For the previous example code p outerHTML returns p b Hello b World p If you write to this property the DOM tree immediately updates to reflect the...

Page 134: ...he tag argument is INPUT the function returns all form elements If a name attribute is specified for one or more tagName objects it must begin with a letter which the HTML 4 01 specification requires...

Page 135: ...bed in the following list The appName property has the value Dreamweaver The appVersion property has a value of the form versionNumber releaseNumber buildNumber languageCode platform As an example the...

Page 136: ...rating system Use this property if you need to include special cases in your extension code for localized operating systems as shown in the following example if dreamweaver systemScript dreamweaver sy...

Page 137: ...167 Chapter 8 Menus and Menu Commands 181 Chapter 9 Toolbars 215 Chapter 10 Reports 249 Chapter 11 Tag Libraries and Editors 261 Chapter 12 Property Inspectors 279 Chapter 13 Floating Panels 289 Chap...

Page 138: ......

Page 139: ...are grouped according to their location on the Insert bar and you can open these files to see the construction of current objects For example you can open the Configuration Objects Common Hyperlink ht...

Page 140: ...e canInsertObject function to determine whether to show a dialog box 2 The Object file is scanned for a FORM tag If a form exists and you select the Show Dialog When Inserting Objects option in the Ge...

Page 141: ...ertbar categorycommon folder Common button id DW_Hyperlink image Common Hyperlink png MMString name insertbar hyperlink file Common Hyperlink htm button id DW_Email image Common E Mail Link png MMStri...

Page 142: ...fines a category on the Insert bar such as Common Forms or HTML The category closing tag specifies the end of the category content Attributes id folder showIf Example category id DW_Insertbar_Common f...

Page 143: ...r Images button id DW_Image image Common Image gif enabled showIf file Common Image htm menubutton button Description This tag defines a button on the Insert bar that the user clicks to execute the co...

Page 144: ...nabled command file tag name codeOnly Example checkbutton id DW_StandardView name Standard View image Tools Standard View gif checked _View_Standard command dw getDocumentDOM setShowLayoutView false s...

Page 145: ...enabler Description This attribute specifies that this button should appear on the Insert bar only if the given Dreamweaver enabler is a true value If you do not specify showIf the button always appe...

Page 146: ...le only in Code view specify the following enabled _VIEW_CODE This dims the button in other views checked enabler Description The checked attribute is required if you use the checkbutton tag The item...

Page 147: ...eamweaver invokes the Tag editor In Design view if codeOnly TRUE and you do not specify the file attribute Dreamweaver MX invokes Split view places focus in the code and invokes the Tag editor Example...

Page 148: ...category tag that represents the category in which you want to move or copy the object 6 Find the location within the category where you want the object to appear 7 Paste the copied button tag 8 Save...

Page 149: ...a set of objects to appear in the category 4 For information on the syntax of the tags in insertbar xml see Insert bar definition tags on page 142 5 Save the insertbar xml file 6 Reload extensions Ad...

Page 150: ...a document Because this example performs text manipulation you may want to explore some of the objects from the Text pop up menu in the HTML category on the Insert bar as models For example look at t...

Page 151: ...he API functions in the HEAD section of the file The existing object files such as Configuration Objects Text Em htm follow a similar pattern of functions and comments The first function the object de...

Page 152: ...oint cursor to the document without any messages or prompting The following procedure shows how the objectTag function now reads To add the objectTag function 1 In the HEAD section of the Strikethroug...

Page 153: ...ethrough js in the Configuration Objects Text folder Creating the image To create the image for the Insert bar 1 Create a GIF image 18 x 18 pixels as shown in the following figure 2 Save the file as S...

Page 154: ...rikethrough gif file Text Strikethrough htm 3 Save the insertbar xml file 4 Reload the extensions see Reloading extensions on page 104 The new object appears at the beginning of the Common category on...

Page 155: ...e return 2 Save the file as Strikethrough js Next in the Strikethrough htm file you add the form The form for this example is a simple checkbox that calls the fontColorRed function when the user click...

Page 156: ...Save the file as Strikethrough htm 3 Reload the extensions see Reloading extensions on page 104 To test the dialog box 1 Click the Red Text checkbox 2 Click OK to perform the objectTag function which...

Page 157: ...objects in the Editorial category let users make editorial comments in a file and either strike through the content they want to remove or make new content blue To organize the files 1 Create a new Co...

Page 158: ...ng else return script head body body html 3 Save the file as AddBlue htm in the Editorial folder Now you can create an image for the Blue Text Object To create the image 1 Create a GIF file that is 18...

Page 159: ...name Editorial folder Editorial category 3 Reload extensions For information on reloading extensions see Reloading extensions on page 104 The Editorial category appears on the Insert bar 4 Within the...

Page 160: ...er Editorial menubutton id DW_Insertbar_Markup name markup image Editorial Strikethrough gif folder Editorial button id DW_Editorial_Strikethrough image Editorial Strikethrough gif file Editorial Stri...

Page 161: ...le The following code tells Dreamweaver to check to see that the document contains a particular string before allowing the user to insert the selected object function canInsertObject var docStr dw get...

Page 162: ...This function determines whether the object requires a valid DOM to operate If this function returns a true value or if the function is not defined Dreamweaver assumes that the command requires a val...

Page 163: ...nput before inserting code If none of these conditions apply use the objectTag function Arguments None Returns Dreamweaver expects a string that contains an error message or an empty string If it retu...

Page 164: ...the objectTag function returns an empty string or returns nothing The objectTag function returns an empty string or a null value because edits to the document have already been made manually Otherwise...

Page 165: ...nsions are smaller than the size of the entire dialog box because they do not include the area for the OK and Cancel buttons If the returned dimensions do not accommodate all options scroll bars appea...

Page 166: ...166 Insert Bar Objects...

Page 167: ...nds work When a user clicks a menu that contains a command the following events occur 1 Dreamweaver calls the canAcceptCommand function to determine whether the menu item should be disabled If the can...

Page 168: ...ks one of the buttons that is defined by the commandButtons function 9 Dreamweaver executes the associated code The dialog box remains visible until one of the scripts in the command calls the window...

Page 169: ...e a new blank file 2 Add the following code to the file to create the form DOCTYPE HTML SYSTEM Macromedia DWExtension layout engine 5 0 dialog HTML HEAD Copyright 2001 2002 Macromedia Inc All rights r...

Page 170: ...h Dreamweaver calls and one user defined function changeCase which is called from the commandButtons function In this example you will write JavaScript to perform the following tasks Determining wheth...

Page 171: ...of the canAcceptCommand function retrieve the selected text by retrieving the DOM for the user s document and calling the getSelection function on the document object Next the function retrieves the...

Page 172: ...nues to see if the node has children theSelNode hasChildNodes and if the type of the first child node is text theChildren 0 nodeType Node TEXT_NODE If both conditions are true canAcceptCommand returns...

Page 173: ...user clicks them The commandButtons function tells Dreamweaver to call changeCase when the user clicks OK and to call window close when the user clicks Cancel Letting the user specify uppercase or lo...

Page 174: ...c substring 0 theSel 0 selText toUpperCase theWholeDoc substring theSel 1 else theDocEl outerHTML theWholeDoc substring 0 theSel 0 selText toLowerCase theWholeDoc substring theSel 1 Set the selection...

Page 175: ...eCase calls getSelectedNode to retrieve the node that contains the selected text It also retrieves any child nodes theSelNode childNodes in case the selection is a tag that contains text such as b tex...

Page 176: ...he Commands API The custom functions in the Commands API are not required canAcceptCommand Description This function determines whether the command is appropriate for the current selection Arguments N...

Page 177: ...ey are clicked If this function is not defined no buttons appear and the BODY section of the Commands file expands to fill the entire dialog box Arguments None Returns Dreamweaver expects an array tha...

Page 178: ...se otherwise receiveArguments Description This function processes any arguments that pass from a menu item or from the dw runCommand function Arguments arg1 arg2 argN If the arguments attribute is def...

Page 179: ...ightInPixels The returned dimensions are smaller than the size of the entire dialog box because they do not include the area for the OK and Cancel buttons If the returned dimensions do not accommodate...

Page 180: ...180 Commands...

Page 181: ...in a multiuser operating system edit the copy of the file in your user Configuration folder or copy the master menus xml file to your user Configuration folder if Dreamweaver hasn t yet created a vers...

Page 182: ...nd shortcuts that are available only in certain contexts For example Control Y Windows or Command Y Macintosh is the shortcut for Redo but Control Shift Z or Command Shift Z is an alternate shortcut f...

Page 183: ...menubar menu Description Provides information about a menu or submenu to appear in the Dreamweaver menu structure Attributes name app id platform showIf name The name of the menu as it will appear on...

Page 184: ...item tags and one or more separator tags It can also contain other menu tags to create submenus and standard HTML comment tags Container This tag must be contained in a menubar tag Example menu name _...

Page 185: ...mac enabled Provides JavaScript code usually a JavaScript function call that determines whether the menu command is currently enabled If the function returns the value false the menu command is dimme...

Page 186: ...pter 5 The Dreamweaver Document Object Model on page 127 showIf Specifies that the menuitem should appear only if the given Dreamweaver enabler has value true The possible enablers are _SERVERMODEL_AS...

Page 187: ...ently used id The ID for the shortcut list It should be the same as the menu ID for the menu bar or context menu in Dreamweaver that the shortcuts are associated with Valid values are DWMainWindow DWM...

Page 188: ...command attribute You must specify either file or command for each shortcut arguments Provides arguments for Dreamweaver to pass to the code in the JavaScript file that you specify in the file attrib...

Page 189: ...g Example tool name Hand tool id com macromedia dreamweaver tools hand tool tags here tool action Description Contains the key combination and JavaScript to execute when the tool is active and the key...

Page 190: ...to reference the action Contents None empty tag Container This tag must be contained in a tool tag Example activate name Switch to Hand tool key H id DWTools_Hand_Active1 override Description Contain...

Page 191: ...backup copy of the menus xml file 3 Open menus xml in a text editor such as BBEdit HomeSite or Wordpad Don t open it in Dreamweaver 4 Cut an entire menuitem tag from the menuitem at the beginning to t...

Page 192: ...such as HomeSite BBEdit or Wordpad Don t open it in Dreamweaver 4 If you re changing a menu command find the appropriate menuitem tag and change the value of its name attribute If you are changing a m...

Page 193: ...use elsewhere and you didn t remove its other use the shortcut applies only to the first menu command that uses it in menus xml 9 Write your new shortcut in the appropriate location in the Keyboard Sh...

Page 194: ...Jsp JavaBeans JavaBeanMenus xml Items for context menus associated with various server components are specified in XML files in subfolders of the Components folder Menu commands Menu commands make me...

Page 195: ...an change Commands that are in the default Commands menu don t appear on this list and can t be edited using this approach 2 Select a command to rename 3 Enter a new name for it 4 Click Close Path Fil...

Page 196: ...mands work When the user clicks a menu with a menu item that contains a menu command the following events occur 1 If any menuitem tag in the menu contains the dynamic attribute Dreamweaver calls the g...

Page 197: ...g box appears If no dialog box appears the remaining steps do not occur 9 The user selects options in the dialog box Dreamweaver executes event handlers that are associated with the fields as the user...

Page 198: ...ified by the file attribute of the menuitem tag Create the MyMenu htm command file in the Dreamweaver Configuration Menus folder and add the three menu command API functions canAcceptCommand receiveAr...

Page 199: ...ndo and Redo menu items the receiveArguments function calls either the dw undo function or the dw redo function depending on whether the value of the argument arguments 0 is undo or redo The dw undo f...

Page 200: ...1 setMenuText Dreamweaver calls the setMenuText function to determine what text appears for the menu item If you do not define the setMenuText function Dreamweaver uses the text that you specified in...

Page 201: ...pecified in the menuitem tag To make it accessible to Dreamweaver either restart Dreamweaver or reload extensions For information on how to reload extensions see Reloading extensions on page 104 To ru...

Page 202: ...t Explorer browser however the submenu would look like the following figure The name attribute for the first menu item specifies the command file PIB_Dynamic htm This file contains the following line...

Page 203: ...shortcut keys that invoke them Next it appends the string id followed by the name of the browser in single quotes for example id iexplore If the itemID argument is DWPopup_PIB_Default the function pr...

Page 204: ...IB length 0 If both tests are true the function returns the value true If either or both of the tests are false the function returns the value false havePreviewTarget The havePreviewTarget function is...

Page 205: ...alse else if strTemp indexOf 1 bHavePreviewTarget false else if DWfile exists selFile bHavePreviewTarget false else if DWfile getAttributes selFile indexOf D 1 bHavePreviewTarget false else bHavePrevi...

Page 206: ...the code performs a series of tests on the list item If the item is not in the form of a file URL if selFile indexOf urlPrefix 1 it sets the return value to false If the remainder of the string follo...

Page 207: ...the menu browserList dw getBrowserList while i browserList length if browserList i 1 theBrowser theBrowser browserList i i 2 else theBrowser whichBrowser Only launch the browser if we have a valid br...

Page 208: ...loop that examines the list of browsers returned by dw getBrowsersList If the path to a browser in the list matches the path to the primary or secondary browser the function sets the variable theBrow...

Page 209: ...s the only argument Otherwise if the arguments attribute is defined for a menuitem tag the value of that attribute passes to the canAcceptCommand function and to the isCommandChecked receiveArguments...

Page 210: ...p getDynamicContent Description Retrieves the content for the dynamic portion of the menu Arguments menuID The menuID argument is the value of the id attribute in the menuitem tag that is associated w...

Page 211: ...mmand receiveArguments and setMenuText functions as one or more arguments The arguments attribute is useful for distinguishing between two menu items that call the same menu command Returns Dreamweave...

Page 212: ...guments function and to the canAcceptCommand isCommandChecked and setMenuText functions as one or more arguments The arguments attribute is useful for distinguishing between two menu items that call t...

Page 213: ...Text else if whatToDo redo return dw getRedoText else return windowDimensions Description Sets specific dimensions for the Parameters dialog box If this function is not defined the window dimensions a...

Page 214: ...214 Menus and Menu Commands Example The following example of windowDimensions sets the dimensions of the Parameters dialog box to 648 x 520 pixels function windowDimensions return 648 520...

Page 215: ...onfiguration folder The default Dreamweaver toolbars are stored in the toolbars xml file in the Configuration Toolbars folder When Dreamweaver starts it loads all the toolbar files in the Toolbars fol...

Page 216: ...s Dreamweaver toolbars have the following characteristics You can drag and drop toolbars to dock them undock them and reposition them relative to other toolbars You can horizontally dock toolbars to t...

Page 217: ...Dreamweaver toolbar for example the canAcceptCommand function checks to see if there is a current DOM and if the current document is an HTML file If both these conditions are true the function return...

Page 218: ...ROL ID DW_SetTitle label Title tooltip Document Title width 150 file Toolbars MM EditTitle htm The tooltip attribute causes Dreamweaver to display Document Title in a tooltip box when the user places...

Page 219: ...he control The function is as follows function receiveArguments newTitle var dom dw getDocumentDOM if dom dom setTitle newTitle Dreamweaver passes newTitle which is the value that the user enters to t...

Page 220: ...nce to an item using the itemref tag a separator using the separator tag or a complete toolbar item definition for a checkbox or an edit box for example as described in Toolbar item tags on page 226 E...

Page 221: ...rder laying out the items automatically The toolbar file does not specify control over the spacing between the items but you can specify the widths of certain kinds of items Attributes id label contai...

Page 222: ...in the following list top This is the default position so the toolbar appears at the top of the document window If multiple toolbars specify top for a given window type the toolbars appear in the ord...

Page 223: ...ag Example toolbar id MyDWedit_toolbar label Edit include Description Loads toolbar items from the specified file before continuing to load the current file Toolbar items that are defined in the inclu...

Page 224: ...or toolbar items see Item tag attributes on page 232 Contents None Container The toolbar tag or the toolbarset tag Example button id strikeout_button itemref Description Refers to and includes in the...

Page 225: ...he item from a toolbar If both the definition and the reference specify the showIf attribute Dreamweaver shows the item only if both conditions are true The showIf attribute is equivalent to the showI...

Page 226: ...cts the same as the Reference button on the Dreamweaver toolbar Attributes id image tooltip command showIf disabledImage overImage label file domRequired enabled update arguments For a description of...

Page 227: ...e see Item tag attributes on page 232 Contents None Container The toolbar tag or the toolbarset tag Example CHECKBUTTON ID DW_LiveDebug image Toolbars images MM debugview gif disabledImage Toolbars im...

Page 228: ...OM null checked dw getDocumentDOM null dw getDocumentDOM getView code command dw getDocumentDOM setView code update onViewChange menubutton Description A menu button is a button that invokes the conte...

Page 229: ...lect an entry and the menu updates itself based on an attached JavaScript function The dropdown menu looks and acts the same as the Format control in the Text Property inspector except it s a standard...

Page 230: ...ired update arguments For a description of each attribute see Item tag attributes on page 232 Contents None Container The toolbar tag or the toolbarset tag Example COMBOBOX ID Address_URL width 300 to...

Page 231: ...he Dreamweaver Property inspector You can specify a different icon to replace the default icon Attributes id tooltip value command showIf image disabledImage overImage label colorRect file domRequired...

Page 232: ...e item s enabler runs that is according to the value of the update attribute You should use the showIf attribute sparingly You can specify the showIf attribute in the item definition and in a referenc...

Page 233: ...that is specified in the image attribute when the button is disabled Example disabledImage Toolbars images MM codenav_dis gif overImage image_path Optional Dreamweaver ignores the overImage attribute...

Page 234: ...s unless you specify the getMenuID function in an associated command file Dreamweaver ignores the menuID attribute for other types of items This attribute specifies the ID of the menu bar that contain...

Page 235: ...he Design view should be synchronized with the Code view before Dreamweaver runs the associated command If you do not specify this attribute it defaults to a true value This attribute is equivalent to...

Page 236: ...the returned value to the list and displays it In all other cases the script returns the current value to display For pop up menus or combo boxes this value should be one of the items in the menu lis...

Page 237: ...when the application is idle This can be time consuming because the enabler checked showif value handlers are running often It should be used only for buttons that need to have their enable state cha...

Page 238: ...ng example button id DW_Undo image Toolbars images MM undo gif disabledImage Toolbars images MM undo_dis gif tooltip Undo file Menus MM Edit_Clipboard htm arguments undo update onEveryIdle button id D...

Page 239: ...menu has an ID attached Dreamweaver passes that ID to canAcceptCommand instead of the value For combo boxes if the current contents of the text box do not match an entry in the pop up menu Dreamweaver...

Page 240: ...This function is equivalent to the value attribute Arguments None Returns Dreamweaver expects a string that contains the current value to display For the color picker the string contains the RGB form...

Page 241: ...ommand files In the menu command file Dreamweaver ignores the getDynamicContent function because the menu item is not marked as dynamic Arguments None Returns Dreamweaver expects an array of strings w...

Page 242: ...e Returns Dreamweaver expects a string that contains a menu ID which is defined in the menus xml file Example function getMenuID var dom dw getDocumentDOM var menuID if dom var view dom getView var fo...

Page 243: ...ible unlike menus For this reason you should always select the lowest frequency possible and make sure your enabled checked and value handlers are as simple as possible This function is equivalent to...

Page 244: ...ing whether the text box matches Dreamweaver compares against the menu without case sensitivity If you specified the arguments attribute those arguments are passed next If you do not specify the argum...

Page 245: ...t the command requires a valid DOM and synchronizes the Code view and Design view for the document before executing the associated command This function is equivalent to the domRequired attribute in a...

Page 246: ...If you specified the arguments attribute those arguments are passed next If you did not specify the arguments attribute Dreamweaver passes the ID of the item Returns Dreamweaver expects nothing Exampl...

Page 247: ...247 Returns Dreamweaver expects a Boolean value true if the item appears false otherwise Example function showif var retval false var dom dw getDocumentDOM if dom var view dom getView if view design r...

Page 248: ...248 Toolbars...

Page 249: ...ver uses its contents as the category name If _foldername txt is not present Dreamweaver uses the folder name as the category name When the user selects multiple site reports from the Reports dialog b...

Page 250: ...s from the Site Reports tab of the Results panel Dreamweaver calls the beginReporting function in each report before the reporting process begins If a report returns a false value from this function i...

Page 251: ...g box if needed To create the report definition 1 Create the file Configuration Reports HTML Reports List images htm 2 Add the following to specify the name of the report that you want to appear in th...

Page 252: ...unction processFile Description Report command API called during file processing function processFile fileURL if isHTMLType fileURL If the file isn t an HTML file return skip it var curDOM dw getDocum...

Page 253: ...lizes the title and format of the Results window by calling the setTitle and SetColumnWidths functions as methods of the Results window object 3 The command can either start adding items to the Result...

Page 254: ...in the Configuration Commands folder List images htm which defines the UI of the dialog box that appears when the user selects the custom command and Listimages js which contains the JavaScript code...

Page 255: ...0 i tagList length i Get the name of the source file imgfilename tagList i getAttribute src Get the character offset from the start of the file to the start of the img tag iOffset curDOM nodeToOffsets...

Page 256: ...OM when it finishes Arguments strFilePath The strFilePath argument is the full path and filename of the file to process Returns Dreamweaver expects nothing beginReporting Availability Dreamweaver 4 De...

Page 257: ...at should appear on the right side of the Options dialog box and their behavior when they are clicked If this function is not defined no buttons appear and the BODY section of the report file expands...

Page 258: ...rt is selected Arguments None Returns Dreamweaver expects a Boolean value true if the Report Settings button should be enabled false otherwise windowDimensions Availability Dreamweaver 4 Description S...

Page 259: ...ze of the entire dialog box because they do not include the area for the OK and Cancel buttons If the returned dimensions do not accommodate all options scroll bars appear Example The following instan...

Page 260: ...260 Reports...

Page 261: ...stores information about each tag including all tag attributes in a set of subfolders that reside in the Configuration TagLibraries folder The tag editor and Tag Chooser functions use the information...

Page 262: ...t use VTML files in the same way as HomeSite The most important difference is that Dreamweaver contains its own HTML renderer that displays extension user interfaces UIs so the Dreamweaver VTML files...

Page 263: ...Used to refer to the tag library in the UI Mandatory taglibrary doctypes Indicates the document types for which this library is active When the library is active library tags appear in the Code Hints...

Page 264: ...raries vtm file Optional taglibrary tagchooser A relative path to the TagChooser xml file that is associated with this tag library Optional Attribute Description Mandatory optional tagref name Used to...

Page 265: ...vidual tag tag name input bind value casesensitive no endtag no tagformat indentcontents yes formatcontents yes nlbeforetag nlbeforecontents 0 nlaftercontents 0 nlaftertag 1 tagdialog file input HTM a...

Page 266: ...sing tag there is no matching input tag If the closing tag is optional the ENDTAG attribute should be set to Yes tag Specify xml to enforce XML syntax for an empty tag For example tag name foo endtag...

Page 267: ...font family STYLE CSS styles attribute CSSSTYLE CSS class name CSSID CSS class ID FILEPATH a full file path DIRECTORY a folder path FILENAME filename only RELATIVEPATH a relative representation of th...

Page 268: ...ser xml files or create new ones the TAGLIBRARY TAGCHOOSER attribute must point to the correct location for the Tag Chooser to be fully functional If there is no TAGLIBRARY TAGCHOOSER attribute the Ta...

Page 269: ...ally exclusive tclibrary reference Value describes the language topic and subtopic to display in the Tag Info section of the Tag Chooser dialog box Interchangeable with tclibrary desc Optional desc an...

Page 270: ...e Value that is either placed directly into the code or a parameter that passes into visual dialog boxes Mandatory element desc Value is an HTML string and appears in the incorporated Reference panel...

Page 271: ...nd the TagLibraries vtm file in the user s Configuration folder it searches for the file in the Dreamweaver Configuration folder The cfweather tag is a ColdFusion tag so an appropriate tag library gro...

Page 272: ...ather vtm file in the Configuration Taglibraries CFML folder Using the tag definition file Dreamweaver can perform code hinting code completion and tag formatting functionality for the cfweather tag C...

Page 273: ...deObj theUIObjects function initializeUI define two arrays for the values and display captions for the list control var theTempatureScaleCap new Array celsius fahrenheit var theTempatureScaleVal new A...

Page 274: ...odify the TagChooser xml file in the Configuration Taglibraries CFML folder by adding a new category called Third Party Tags which features the cfweather tag as shown in the following example category...

Page 275: ...an argument the tag that the user is editing which is expressed as a dom object The function extracts attribute values from the tag that is being edited and uses these values to initialize form elemen...

Page 276: ...er is entered for the number of table rows The validateTag function detects the invalid input displays an alert message and returns a false value applyTag Availability Dreamweaver MX Description When...

Page 277: ...cfweather example in the following code if the user changes the ZIP code from 94065 to 53402 in order to update the user s document to use the new ZIP code the dom object must be updated function appl...

Page 278: ...278 Tag Libraries and Editors...

Page 279: ...or create new ones to inspect custom tags Custom Property inspector files reside in the Configuration Inspectors folder inside the Dreamweaver application folder The following table lists the files y...

Page 280: ...indicates the server model of the Property inspector If the server model of the Property inspector is not the same as the server model for the document Dreamweaver does not use the Property inspector...

Page 281: ...has one or more inspectors Dreamweaver calls each inspector s canInspectSelection function If this function returns the value false Dreamweaver no longer considers the inspector a candidate for inspec...

Page 282: ...perty inspector To create the user interface 1 Create a new blank file 2 As the first line of the file add the comment that identifies the property inspector as follows tag MARQUEE priority 9 selectio...

Page 283: ...ght Right OPTION SELECT TR TABLE FORM SPAN 5 Save the file as marquee htm in the Configuration Inspectors folder Writing the JavaScript code You need to add JavaScript functions to make sure you can i...

Page 284: ...ionIndex 1 document topLayer document topLayerForm marqDirection selectedIndex directionIndex 4 To get the current selection and make the text box in the Property inspector display the direction attri...

Page 285: ...Restart Dreamweaver 2 Create a new HTML page or open an existing HTML page 3 Add the following in the BODY section of the page MARQUEE MARQUEE 4 Highlight the text you just added The Property inspecto...

Page 286: ...theObj hasAttribute classid theObj getAttribute classid toLowerCase clsid D27CDB6E AE6D 11cf 96B8 444553540000 displayHelp Description If this function is defined a question mark icon appears in the u...

Page 287: ...ng on whether the Property inspector is in its expanded or contracted state Returns Dreamweaver expects nothing Example The following example of the inspectSelection function gets the value of the CON...

Page 288: ...288 Property Inspectors...

Page 289: ...d to form elements can call JavaScript code that performs arbitrary edits to the current document Dreamweaver has several built in floating panels that are accessible from the Window menu These built...

Page 290: ...ity dreamweaver setFloaterVisibility or dreamweaver toggleFloater For more information on these functions see the Dreamweaver API Reference When one of the files inside the Configuration folder calls...

Page 291: ...visible at the last shutdown and displays the floating panels in their last position and tab grouping A simple floating panel example In this example you create a Script Editor extension that creates...

Page 292: ...ese two floating panels or layers called blanklayer and scriptlayer To create the two floating panels 1 Add the following code after the header in the HTML file body div id blanklayer style position a...

Page 293: ...the selected code has changed the updateScript function is called to write the changed text back to the document Writing the JavaScript code The JavaScript code for the Script Editor consists of one...

Page 294: ...ected node for that document is first an element and second a SCRIPT tag If both these conditions are true the selectionChanged function makes the scripteditor floating panel visible and loads it with...

Page 295: ...Configuration Floaters folder 2 Enter the following code in the header section of the file function selectionChanged get the selected node var theDOM dw getDocumentDOM var theNode theDOM getSelectedNo...

Page 296: ...tion updateScript var theDOM dw getDocumentDOM var theNode theDOM getSelectedNode theNode innerHTML document layers scriptlayer document theForm scriptCode value script head 3 Save the file Creating a...

Page 297: ...Tile _Vertically and position the cursor after the closing of the tag 3 On a new line insert the following menuitem name Script Editor enabled true command dw toggleFloater scriptEditor checked dw get...

Page 298: ...be defined only if the floating panel must track edits to the document Arguments None Returns Dreamweaver expects nothing Example The following example of the documentEdited function scans the docume...

Page 299: ...side of the Dreamweaver workspace or to each other Arguments None Returns Dreamweaver expects a string containing the words left right top and bottom or a combination of them that specifies where Dre...

Page 300: ...ion Determines which other floating panels are tabbed together the first time that this floating panel appears If any listed floating panel has appeared previously it is not included in the tab group...

Page 301: ...bine this panel with others Arguments None Returns Dreamweaver expects a Boolean value true if other floating panels can dock to this one false otherwise Example IsATarget return true isAvailableInCod...

Page 302: ...anel false otherwise Example The following example prevents the user from resizing the floating panel function isResizable return false selectionChanged Description Called when the floating panel beco...

Page 303: ...ctionChanged functions are called after every keystroke and mouse click when Dreamweaver is idle for more than one tenth of a second It s important to use different scenarios to test your floating pan...

Page 304: ...processing the previous edit then the timer is already set if document running false setTimeout processLayer 500 set the processing flag to true document running true process one layer function proces...

Page 305: ...t indicate which layers to display or hide The HEAD section of an Action file contains JavaScript functions that process form input from the BODY content and control the functions arguments and event...

Page 306: ...m the Event file 2 The user selects an action from the Actions pop up menu 3 Dreamweaver calls the windowDimensions function to determine the size of the Parameters dialog box If the windowDimensions...

Page 307: ...This is a link return true But if Dreamweaver inserts the return behaviorName args action into the event handler behaviors later in the list are skipped To get around this limitation set the document...

Page 308: ...rand title meta http equiv Content Type content text html script language JavaScript The function that will be inserted into the HEAD of the user s document function checkBrowserBrand netscapeURL expl...

Page 309: ...the contents if any function initializeUI document theForm nsURL focus document theForm nsURL select Let the user browse to the Navigator and IE URLs function browseForURLs whichButton var theURL dre...

Page 310: ...es to browse 1 Create a new file with the following content DOCTYPE HTML PUBLIC W3C DTD HTML 4 01 Transitional EN http www w3 org TR html4 loose dtd html head meta http equiv Content Type content text...

Page 311: ...to the URL if the browser is Netscape Navigator text box and select the netscapecontent htm file 10 Click the Browse button next to the Go to the URL if the browser is Internet Explorer text box and...

Page 312: ...nserts into the user s document an event handler that calls the function that the behaviorFunction function inserts The applyBehavior function can also perform other edits on the user s document but i...

Page 313: ...user specified parameters the height and width of the window whether the window should have scroll bars a toolbar a location bar and other features and the URL that should open in the window function...

Page 314: ...erted only once regardless of how many times the action is applied to elements in the document Example The following instance of the behaviorFunction function returns the MM_popupMsg function function...

Page 315: ...nding order of preference for this action Specifying preferred events overrides the default event as denoted with an asterisk in the Event file for the selected object See step 1 in How Behaviors work...

Page 316: ...nsHelp superDuperHelp htm dw browseDocument myHelpFile deleteBehavior Description This function undoes any edits that the applyBehavior function performed Arguments applyBehaviorString This argument i...

Page 317: ...ifies that the argument is a navigational URL and therefore it should appear in the site map The dep argument type specifies that the argument is a dependent file URL and therefore it should be includ...

Page 318: ...n with a minimum number of arguments of 4 may have 4 8 or 12 arguments but it cannot have 10 arguments function identifyBehaviorArguments fnCallStr var listOfArgTypes var itemArray dreamweaver getToke...

Page 319: ...at the user selected when the behavior was originally applied function inspectBehavior msgStr var startStr msgStr indexOf 1 var endStr msgStr lastIndexOf if startStr 0 endStr startStr document theForm...

Page 320: ...e smaller than the size of the entire dialog box because they do not include the area for the OK and Cancel buttons If the returned dimensions do not accommodate all options scroll bars appear Example...

Page 321: ...pports server behavior extensions that add runtime code for the following server models ASP Net C ASP Net VisualBasic ASP JavaScript ASP VBScript ColdFusion JSP and PHP MySQL The following terms are u...

Page 322: ...additional functionality The architecture simplifies your implementation of the API and also separates your runtime code from how Dreamweaver deploys it This chapter discusses ways of modifying these...

Page 323: ...e_attr partType identifier groupParticipants group In the groupParticipants block tag each groupParticipant tag indicates the EDML participant file that contains the code block to use The value of the...

Page 324: ...untime code and extracts specific parameters For more details see Server behavior techniques on page 369 The script file Each server behavior also has an HTML file that contains functions and links to...

Page 325: ...2 In the New Server Behavior dialog box select Document Type ASP JavaScript and Name Hello World Leave the Copy existing server behavior checkbox unchecked 3 Click OK Defining the code to insert Final...

Page 326: ...object If it is implemented Dreamweaver calls the analyzeServerBehavior function for each behavior instance that is found in the user s document after all the findServerBehaviors functions are called...

Page 327: ...button in the Server Behaviors panel the pop up menu appears To determine the content of the menu Dreamweaver first looks for a ServerBehaviors xml file in the same folder as the behaviors ServerBehav...

Page 328: ...the copyServerBehavior function returns Dreamweaver converts the server behavior object to a form that can be put on the Clipboard When Dreamweaver converts the object it deletes all the properties t...

Page 329: ...nction is to notice when two or more behaviors refer to the same tag in the user s document In this case the deleted property removes all but one behavior from the array Suppose the Recordset1 Dynamic...

Page 330: ...the user s document Dreamweaver calls this function when the user clicks OK in the Server Behaviors dialog box If this function returns successfully the Server Behaviors dialog box closes If this fun...

Page 331: ...Behavior function is optional Users can copy instances of the specified server behavior In the following example this function is implemented for recordsets If a user selects a recordset in the Server...

Page 332: ...ocument It is called when the user clicks the Minus button on the Server Behaviors panel It can edit a user s document For more information see dwscripts deleteSB on page 337 Arguments serverBehavior...

Page 333: ...finds the findServerBehaviors function creates a JavaScript object and it attaches state information as JavaScript properties of the object The four required properties are incomplete participants ti...

Page 334: ...ehavior Dreamweaver organizes the contents of the Clipboard and generates a new behavior object The new object is identical to the original except that it lacks pointer properties Dreamweaver passes t...

Page 335: ...y weights array types array selectedNode value and incomplete flag This function also creates a parameter object that holds an array of user definable properties such as recordset name and column name...

Page 336: ...rtion text Arguments paramObj sbObj The paramObj argument is the object that contains the user parameters The sbObj argument is the prior server behavior object if you are updating an existing server...

Page 337: ...that you want to remove from the user s document Returns Dreamweaver expects nothing Example The following example deletes all the participants of the sbObj server behavior except the participants th...

Page 338: ...or parameter values need to be extracted from the instances of the runtime code You use regular expressions for the extraction process You should understand a few metacharacters and metasequences spec...

Page 339: ...e code The CDATA tag represents character data and is any text that is not EDML markup When you use the CDATA tag the EDML parser won t try to interpret it as markup but instead considers it as a bloc...

Page 340: ...in the EDML group files group Description This tag contains all the specifications for a group of participants Parent None Type Block tag Required Yes group attributes The following items are valid at...

Page 341: ...weaver call the findServerBehaviors function In some cases if multiple groups are associated with a single server behavior the server behavior must resolve which particular group to use Parent group T...

Page 342: ...vior Repeat Region htm dataSource myCOMdataSource htm This group defines a new implementation of the Repeat Region server behavior to use if you use the COM data source In the applyServerBehaviors fun...

Page 343: ...rtVersion attribute In the applyServerBehaviors function you can indicate which group should be applied by setting the MM_subType property on the parameter object as shown in the following example fun...

Page 344: ...tag Required Yes groupParticipants attributes The following items are valid attributes of the groupParticipants tag selectParticipant Description Indicates which participant should be selected and hig...

Page 345: ...on This tag represents the inclusion of a single participant in the group Parent groupParticipants Type Tag Required Yes at least one groupParticipant attributes The following items are valid attribut...

Page 346: ...default value if the partType attribute is not specified The member value is a normal member of a group If it is found by itself it does not identify a group If it is not found in a group the group i...

Page 347: ...this release of Dreamweaver all groups and participants that the Server Behavior Builder creates have the version attribute set to 7 0 For participant files this attribute determines if code block mer...

Page 348: ...ue is a literal string that exists on the page if the participant exists The string should be as unique as possible to maximize performance but the string does not have to be definitively unique It is...

Page 349: ...igns Because this text can interfere with the EDML structure it should use the CDATA construct as shown in the following example insertText location aboveHTML CDATA recordset cursorType insertText Whe...

Page 350: ...provided it is internally assigned a weight of 100 and is added below all specifically weighted participants as shown in the following example insert location aboveHTML The belowHTML weight value is...

Page 351: ...g useful for adding hidden form fields nodeAttribute attribute sets an attribute of a tag node If the attribute does not already exist this value creates it For example use insert location nodeAttribu...

Page 352: ...dwscripts applySB paramObj sbObj You can indicate the form__tag node parameter in your EDML file as shown in the following example insertText location lastChildOfNode nodeParamName form__tag CDATA in...

Page 353: ...erver specific tags For ASP and JSP this means search all script blocks The tag tagName value searches the contents of a specified tag as shown in the following example searchPatterns whereToSearch ta...

Page 354: ...nd extracts parameter values from it Each parameter subexpression must be enclosed in parentheses You can have patterns with no parameters which are used to identify participant text patterns with one...

Page 355: ...rn searchPattern paramNames optionLabel limitSearch innerOnly searchPattern searchPatterns This example sets the optionLabel parameter to the entire innerHTML contents of an OPTION tag searchPattern a...

Page 356: ...ct multiple parameters using a single pattern use a comma separated list of parameter names in the order that the subexpressions appear in the pattern Suppose the following example shows your search p...

Page 357: ...rched If that attribute is not defined the tag is ignored The tagOnly value searches only the outer tag and ignores the innerHTML tag This value is valid only if whereToSearch is a tag The innerOnly v...

Page 358: ...wing example searchPattern paramNames rs var w Server CreateObject searchPattern searchPattern paramNames src ActiveConnection r n searchPattern searchPattern paramNames conn Source r n searchPattern...

Page 359: ...ter between two parenthetical subexpressions in the form pre pattern parameter pattern post pattern You need to define at least one update pattern for each unique paramName in the insertion text The f...

Page 360: ...wing example Recordset1 CursorType 0 Recordset1 CursorLocation 2 Recordset1 LockType 3 To update the recordset name in all three positions you need three update patterns for a single parameter as show...

Page 361: ...participant Without this tag the participant is deleted by removing it completely but only if no server behaviors refer to it By specifying a delete tag you can specify that it should never be deleted...

Page 362: ...nnerHTML tag For attributes it removes only the value It is meaningless for directives The attribute attribName value when applied to tags removes only the specified attribute It is meaningless for di...

Page 363: ...thin the text being searched the search patterns have a logical AND relationship unless they are marked as optional using the isOptional flag Parent translator Type Block tag Required Yes translations...

Page 364: ...e Block tag Required No translation attributes The following items are valid attributes of the translation tag whereToSearch Description This attribute specifies where to search for the text which is...

Page 365: ...a dynamic image dynamic source tabbed region start tabbed region end custom The dynamic data value indicates that the translated directives look and behave the same as Dreamweaver dynamic data as show...

Page 366: ...l Dreamweaver functionality is added to the translation It is often used when specifying a tag to insert for a custom Property inspector as shown in the following example translation whereToSearch dir...

Page 367: ...Required No attribute Description This tag specifies a single attribute or translated attribute to add to the translated tag Parent attributes Type Block tag Required Yes at least one Values The attr...

Page 368: ...rs col display causes the translation to render as myRecordset myCol closeTag Description This optional tag should be inserted at the end of the translated section This tag enables certain other exte...

Page 369: ...process of finding server behavior instances If this string is found in the document and the participant identifies a server behavior in the group file partType identifier for this participant the re...

Page 370: ...h as a telephone number For such an example you could use the following ASP code address block LNAME joe FNAME smith PHONE 123 4567 You could use the following search patterns quickSearch address quic...

Page 371: ...ically matched as shown in the following example of a server behavior with group file group serverBehavior test htm title Test title groupParticipants groupParticipant name test_p1 partType identifier...

Page 372: ...lection here end mySBName More HTML here if expression mySBName Another HTML selection here end mySBName Now there are two identical instances of each participant which is allowed within the HTML They...

Page 373: ...as those for include files When Dreamweaver creates server models it builds lists of patterns by scanning all the participants for special paramNames attributes To find URLs to check file dependency...

Page 374: ...ayer Dreamweaver internally splits the document into directives straight text and tags parsed into an efficient tree structure Updating server behaviors Replacement update By default participant EDML...

Page 375: ...F searchPattern searchPattern paramNames new__url if s r n s Response Redirect r n i searchPattern searchPatterns These shortened search patterns are flexible so the user can add to the code However i...

Page 376: ...o limit participant deletion There might be cases where you want to limit the way that participants are deleted This can be achieved by adding a delete tag to the EDML file The following example shows...

Page 377: ...the code is implicitly included in all HTML files thereafter NO TE Because JavaScript files that are loaded into this central location share memory the files cannot duplicate any declarations If a sha...

Page 378: ...378 Server Behaviors...

Page 379: ...JSP and PHP MySQL Within each server model subfolder are HTML and EDML files that are associated with the data sources for that server model The following table lists the files you use to create a da...

Page 380: ...he filename is used in the menu After Dreamweaver finishes reading the DataSources xml file or if the file does not exist Dreamweaver searches the rest of the folder to find other items that should ap...

Page 381: ...namic Text dialog box or clicks Insert or Bind in the Bindings panel Dreamweaver calls the generateDynamicDataRef function The return value is inserted in the document at the current insertion point 7...

Page 382: ...el for Macromedia ColdFusion documents Users can specify the variable they want from the new data source This example creates a data source called MyDatasource which includes a MyDatasource js JavaScr...

Page 383: ...of the findDynamicSources function To create the data source definition file 1 Create a new blank file 2 Enter the following HTML HEAD TITLE MyDatasource TITLE SCRIPT SRC Shared Common Scripts dwscri...

Page 384: ...he name of the supporting script files and the code for the working Dreamweaver document you need to specify the JavaScript functions for Dreamweaver to provide the user with the ability to add insert...

Page 385: ...e function findDynamicSources var retList new Array var siteURL dw getSiteRoot if siteURL length var bindingsArray dwscripts getListValuesFromNote siteURL MyDatasource if bindingsArray length 0 Here y...

Page 386: ...taRef sourceName bindingName dropObject var paramObj new Object paramObj bindingName bindingName var retStr extPart getInsertString MyDatasource_DataRef paramObj We need to strip the cfoutput tags if...

Page 387: ...DynamicSource function contains the command dw popupCommand MyDatasrouce_Variable which opens a dialog box for the user to enter a specific variable name However you still need to create the dialog bo...

Page 388: ...head body form div ALIGN center table border 0 cellpadding 2 cellspacing 4 tr td align right valign baseline nowrap Name td td valign baseline nowrap input name theName type text class medTField td t...

Page 389: ...mName else alert MM MSG_NoName 3 Save the file as MyDatasource_Variable js in the Configuration Commands folder Testing the new data source You can now open Dreamweaver or restart it if you already ha...

Page 390: ...g box you created appears 3 Enter a value in the dialog box and click OK The Bindings panel displays the data source in a tree with the variable from the dialog box under the data source name 4 Drag t...

Page 391: ...eamweaver calls the dw serverBehaviorInspector popupServerBehavior function which inserts a new server behavior into the document For request session and application variables Dreamweaver displays an...

Page 392: ...f all the data sources for the user s document Arguments sourceName bindingName The sourceName argument is the name of the top level node to which the child node is associated The bindingName argument...

Page 393: ...ame The sourceName argument is the name of the top level node to which the child node is associated The bindingName argument is the name of the child node Returns Dreamweaver expects a Boolean value t...

Page 394: ...rce property is the simple name of the file in which the findDynamicSources function is defined For example the findDynamicSources function in the Session htm file which is located in the Configuratio...

Page 395: ...children of a top level node Arguments sourceName The sourceName argument is the name of the top level node whose children you want to return Returns Dreamweaver expects an array of JavaScript object...

Page 396: ...es the corresponding node in the data source tree from a dynamic data object The inspectDynamicDataRef function takes the string that Dreamweaver passes in and compares it to the string that generateD...

Page 397: ...I 397 Arguments string The string argument is the dynamic data object Returns Dreamweaver expects an array of two elements parent name and child name for the matched node it returns a null value if no...

Page 398: ...398 Data Sources...

Page 399: ...e user s document Before inserting the string into the user s document Dreamweaver passes that string to the formatDynamicDataRef function which is described in this chapter The string that the format...

Page 400: ...eName attribute is the HTML file for this format type such as Currency The title string attribute is the string that appears in the Format menu such as Currency default The expression regexp attribute...

Page 401: ...format The Edit Format List Plus menu If you do not want a file in the ServerFormats folder to appear in the Edit Format List Plus menu add the following statement as the first line of the HTML file M...

Page 402: ...e deleteFormat function removes the support scripts from the document When the user clicks the Plus button in the Edit Format List dialog box Dreamweaver displays a menu that contains all the format t...

Page 403: ...propriate format function Dreamweaver adds the function declaration by calling the applyFormat JavaScript function in the data format file It changes the dynamic data object by calling the formatDynam...

Page 404: ...ction completes successfully If an error occurs the function returns an error string If it returns an empty string the form is closed but the new format is not created which is the same as a Cancel op...

Page 405: ...data object by calling the formatDynamicDataRef function The formatDynamicDataRef function is called when the user selects a format from the Format text box in the Dynamic Data or the Dynamic Text dia...

Page 406: ...n the Edit Format List dialog box Arguments format The format argument is a JavaScript object that describes the format to apply The JavaScript object is the node that corresponds to the format tag in...

Page 407: ...erent technologies offer programmers different ways to accomplish this encapsulation and different names describe these strategies functions modules and others Macromedia Dreamweaver 8 uses the term c...

Page 408: ...ture of the component and making its fields methods and properties available through Dreamweaver Finally server models such as ASP NET JSP J2EE or ColdFusion tend to support some but not all component...

Page 409: ...Component files are stored in the Configuration Components server model ComponentType folder You can add other server models and supporting server extensions for more information see Chapter 19 Server...

Page 410: ...ename Description Required Optional htm The extension file that identifies other supporting JavaScript and GIF files Required js The extension file that implements the Component API callback Required...

Page 411: ...e in a tree control must have the following properties TI P When adding a new service you might want to use the Components panel to browse meta information so that the information is readily available...

Page 412: ...the API functions for populating the Components panel getComponentChildren Availability Dreamweaver MX Description This function returns a list of child ComponentRec objects for the active parent Comp...

Page 413: ...return DWWebServicesContext Where DWWebServicesContext is defined in the file in the Configuration Components ASP NET_CSharp WebServices WebServicesMenus xml as follows shortcutlist id DWWebServicesCo...

Page 414: ...ent Example The following example identifies the code for a common web service function getCodeViewDropCode componentRec var codeToDrop if componentRec if componentRec objectType Class codeToDrop dw g...

Page 415: ...he text instructions which can include any HTML markup that is legal inside a li tag You can include hypertext links a tags in the list of steps by using the following form a href onMouseDown handler...

Page 416: ...me else var aServerModelName site getServerDisplayNameForSite if aServerModelName length if aServerModelName ColdFusion if needsSDKInstalled null doSDK needsSDKInstalled var someSteps new Array someSt...

Page 417: ...anel or a component from the Components panel to the Design view Arguments componentRec The componentRec argument is an object that contains the following properties The name property is the name of t...

Page 418: ...e if componentRec if componentRec objectType Table componentRec objectType View alert popup Recordset Server Behavior bHandled true return bHandled handleDoubleClick Availability Dreamweaver MX Descri...

Page 419: ...a Boolean value that indicates whether the tree node item can be dragged and dropped into Code view The isDesignViewDraggable property is a Boolean value that indicates whether the tree node item can...

Page 420: ...ext Tooltip for the toolbar button toolStyle Left right enabled JavaScript code that returns a Boolean value true or false The enablers are called when the following conditions exist When the dreamwea...

Page 421: ...utton disabledImage PLUS_BUTTON_UP plusButton toolStyle left plusButton toolTipText MM MSG_WebServicesAddToolTipText plusButton enabled dwscripts IS_WIN plusButton command invokeWebService else plusBu...

Page 422: ...ONDOWN deployWServiceButton disabledImage DEPLOYSUPPORTBUTTONUP deployWServiceButton toolStyle right deployWServiceButton toolTipText MM MSG_WebServicesDeployToolTipText deployWServiceButton command s...

Page 423: ...weaver For cases when the user does not identify a server model you can create a dynamic dialog box that prompts the user to complete the necessary steps This dialog box appears when the user attempts...

Page 424: ...weaver getDocumentDOM function Returns Dreamweaver expects an integer that indicates the priority that you give to the server model for the file extension This function should return a value of 1 if t...

Page 425: ...lity Dreamweaver MX Description This function returns an object that describes the method and array signatures that the scripting language uses The getLanguageSignatures function helps map generic sig...

Page 426: ...es are located in the Configuration ServerModels folder Arguments None Returns Dreamweaver expects an object that defines the scripting language signatures This object should map the generic signature...

Page 427: ...0 return obj getServerLanguages Availability Dreamweaver UltraDev 1 deprecated in Dreamweaver MX Description This function returns the supported scripting languages of a server model with an array of...

Page 428: ...he supported scripting languages getServerModelExtDataNameUD4 Availability Dreamweaver MX Description This function returns the server model implementation name that Dreamweaver should use when access...

Page 429: ...rticipateInMerge property is a Boolean value that specifies whether the content enclosed in the listed delimiters should true or should not false participate in block merging getServerModelDisplayName...

Page 430: ...r supports the specified character set From JavaScript you can determine whether the server model supports a specific character set by calling the dom serverModel getServerSupportsCharset function Arg...

Page 431: ...r Model API functions 431 Arguments None Returns Dreamweaver expects an array of version objects each with a version name and version value as listed in the following examples ASP version 2 0 ADODB ve...

Page 432: ...432 Server Models...

Page 433: ...do not require locks which makes it simple to inspect the tags that contain them Data translation especially for entire tags or blocks of code might involve complex operations that either cannot be d...

Page 434: ...n view after making changes in the HTML panel or in Code view Changes the properties of an object in the current document Inserts an object using either the Objects panel or the Insert menu Refreshes...

Page 435: ...aver You must write a custom Property inspector for the translated content if you want users to be able to change the properties of the original code see Locking translated tags or blocks of code on p...

Page 436: ...nslatedValue attribute can contain more than one valid attribute value pair Consider the following untranslated code img if dayType weekday then src open jpg width 320 height 100 else src closed jpg w...

Page 437: ...attributes If both a translated value and a regular value are set for a particular attribute Dreamweaver displays the translated value in the Document window You must decide whether your translator s...

Page 438: ...spectors For example specifying type IMG does not make the Image panel appear The dependentFilesList value is a string that contains a comma separated list of files on which the locked markup depends...

Page 439: ...eaver getSelection and dreamweaver nodeToOffsets functions act on the untranslated source The tags you inspect are different before and after translation A Property inspector for the HAPPY tag might h...

Page 440: ...tches this Property inspector as shown in the following example if theSelection nodeType node ELEMENT_NODE theSelection getAttribute type happy return true else return false To populate the text boxes...

Page 441: ...omment into the document replacing the old one by rewriting the contents of the document which generates a new orig attribute The following code summarizes this technique Assemble the new include comm...

Page 442: ...add the following function function commandButtons return new Array OK translateMarkup dreamweaver getDocumentPath document dreamweaver getSiteRoot dreamweaver getDocumentDOM documentElement outerHTM...

Page 443: ...etter understand attribute translation it s helpful to look at an example The following translator is Pound Conditional Poco markup a syntax that s somewhat similar to ASP or PHP You create the attrib...

Page 444: ...pe content text html charset script language JavaScript This translator handles the following statement syntaxes if condition then foo else bar if condition then att foo else att bar if condition then...

Page 445: ...tokens An array of all the attributes set in the true case var end The end of the current conditional statement As long as there s still a conditional that hasn t been translated while start 1 back3F...

Page 446: ...okens j if j 0 spacer transAtt spacer tokens j transAtt outStr outStr substring 0 end 3 transAtt outStr substring end 3 If attAndValue is true and tokens is not greater than 1 then trueValue is a sing...

Page 447: ...any functionality The following translator example would be more efficient if it were written in C but the JavaScript version is simpler which makes it perfect for demonstrating how translators work A...

Page 448: ...y 5 byExpression run if the file contains kent return returnArray The translateMarkup function performs the actual translation In this translator the translateMarkup function is written entirely in Ja...

Page 449: ...6 Use the string you just created for the next trip through the document This is the most inefficient part of all inStr outStr start inStr indexOf kent When there are no more KENT tags in the document...

Page 450: ...r day today getUTCDay Day of the week in the GMT time zone 0 Sunday 1 Monday and so on var hour today getUTCHours The current hour in GMT based on the 24 hour clock var SFhour hour 8 The time in San F...

Page 451: ...e if SFhour 16 SFhour 17 If user is on Mac show Kent working on Mac if platform MacPPC imageRef images kent_gettingStartedOnMac jpg If user is on Win show Kent working on Win else imageRef images kent...

Page 452: ...pecifies the number of file extensions to follow If nExtensions is zero the translator can run on any file If nExtensions is zero nRegExps is the next element in the array 4 The extension string speci...

Page 453: ...nfo var transArray new Array 11 transArray 0 SSI transArray 1 Server Side Includes transArray 2 4 transArray 3 htm transArray 4 stm transArray 5 html transArray 6 shtml transArray 7 2 transArray 8 inc...

Page 454: ...a string that contains the contents of the document Returns A string that contains the translated document or an empty string if nothing is translated Example The following instance of the translateMa...

Page 455: ...that contains the file URL for the root of the site that contains the document to be translated If the document is outside a site this string might be empty The docContent argument is a string that co...

Page 456: ...456 Data Translators...

Page 457: ...efine a Dreamweaver object that inserts the contents of a user specified file into the current document Because client side JavaScript does not provide support file input output I O you must write a f...

Page 458: ...Convert the argument to a string fileName JS_ValueToString cx argv 0 length if fileName NULL JS_ReportError cx The argument must be a string 0 return JS_FALSE Use the string the file name to open and...

Page 459: ...ons When the function is called to parse the arguments that JavaScript is passing to C Before the function returns to package the return value To accomplish these tasks the interpreter defines several...

Page 460: ...pe passes to the C level function This data type represents an object which might be an array object or some other object type typedef struct jsval jsval An opaque data structure that can contain an i...

Page 461: ...arguments being passed to the function The argv pointer is a pointer to an array of jsval structures The array is argc elements in length The rval pointer is a pointer to a single jsval structure The...

Page 462: ...x jsval v unsigned int pLength The cx argument is the opaque JSContext pointer that passes to the JavaScript function The v argument is the jsval structure from which the string is to be extracted The...

Page 463: ...rguments JSContext cx jsval v double dp The cx argument is the opaque JSContext pointer that passed to the JavaScript function The v argument is the jsval structure from which the double is to be extr...

Page 464: ...he object is to be extracted The op argument is a pointer to a JSObject pointer This function stores the converted value in op Returns A Boolean value JS_TRUE indicates success JS_FALSE indicates fail...

Page 465: ...text pointer that passes to the JavaScript function The dv argument is an 8 byte floating point number The vp argument is a pointer to the jsval structure into which the contents of the double should...

Page 466: ...ine its contents Arguments JSObject obj The obj argument is a pointer to the JSObject object that you want to convert to a JSVal structure Returns A JSVal structure that contains the object that you p...

Page 467: ...hold The v argument is an optional pointer to the jsvals to be stored in the array If the return value is not null v is an array that contains length elements If the return value is null the initial...

Page 468: ...ructure in the array should be copied Returns A Boolean value JS_TRUE indicates success JS_FALSE indicates failure JSBool JS_SetElement Description This function writes a single element of an array ob...

Page 469: ...the null terminated string is computed automatically The rval argument is a pointer to a single jsval structure The function s return value is stored in rval Returns A Boolean value JS_TRUE indicates...

Page 470: ...ting systems to create and maintain individual configurations Dreamweaver creates a separate Configuration folder for each user Whenever Dreamweaver or a JavaScript extension writes to the Dreamweaver...

Page 471: ...Dreamweaver Configuration Objects Common Table htm Dreamweaver searches for a Table htm file in the C Documents and Settings username Macromedia Dreamweaver Configuration Objects Common folder and if...

Page 472: ...ries to call dw getDocumentDom file c Program Files Macromedia Dreamweaver Configuration Snippets javascript onepixelborder csn it returns a null value You can modify the mm_deleted_files xml file to...

Page 473: ...mweaver MX Description This function checks whether the specified file exists If it is a file in a configuration folder the function searches for the file in the user Configuration folder or the Dream...

Page 474: ...Configuration folder the MM_OpenConfigFile function resolves the path before opening the file The char mode argument points to a string that specifies how you want to open the file You can specify nu...

Page 475: ...r the MM_GetConfigFileAttributes function resolves the path before opening the file The unsigned long attrs argument is the address of an integer that contains the returned attribute bits see JSBool M...

Page 476: ...the specified file URL is in the Dreamweaver Configuration folder this function first copies the file to the user Configuration folder before it sets the attributes If the attributes are the same as t...

Page 477: ...folder within the Dreamweaver Configuration folder the function creates the folder in the user Configuration folder If fileURL does not specify a folder in the Dreamweaver Configuration folder the fun...

Page 478: ...FALSE indicates failure Example char dwConfig file c Program Files Macromedia Dreamweaver Configuration Objects MM_RemoveConfigFolder dwConfig JSBool MM_DeleteConfigFile Availability Dreamweaver MX De...

Page 479: ...nfo h file provides access to the Design Notes API The Sample c example file defines the computeSum function The Sample mak makefile lets you build the Sample c source file into a DLL with Microsoft V...

Page 480: ...tion folder within the Dreamweaver application folder 2 Copy Sample dll Windows or Sample bundle Macintosh to the JSExtensions folder 3 In a text editor open the HR htm file in the Configuration Objec...

Page 481: ...481 4 PART 4 Appendix Find information about supporting files and reference resources that can aid in developing Macromedia Dreamweaver 8 extensions Appendix The Shared Folder 483...

Page 482: ......

Page 483: ...d folder contents The Shared folder has subfolders that contain files shared by multiple extensions including functions for browsing a user s folder system inserting a tree control creating editable g...

Page 484: ...findDynamicSources DBTreeControlClass js Contains functions that build a database tree control This class is used to create and interact with a database tree control To create a database tree control...

Page 485: ...xample calling a stored procedure using SQL to return a recordset and so on This is an abstract base class which means that it cannot be created and used on its own To use it you must subclass SBDatab...

Page 486: ...tributes from within the opening tag of a given node parse a CFC tree get the current URL DOM get the CFC DOM and more event js Contains functions to register events notify parties of events from the...

Page 487: ...tween the UIs sbUtils js Contains shared functions for use within Macromedia server behaviors The dwscripts class in the Configuration Shared Common Scripts folder contains more general purpose utilit...

Page 488: ...PreferencesClass js Contains an object and methods that contain all the preference information for a command RadioGroupClass js Older version of the RadioGroupClass in the Common folder See the Radio...

Page 489: ...rmine if a specified file is currently open form js Contains functions that add a form around a given text string if a form does not already exist in the current document or layer Includes functions t...

Page 490: ...location each time string js Contains a generic set of functions for manipulating and parsing text strings Functions include extractArgs escQuotes unescQuotes quoteMeta errMsg badChars getParam quote...

Page 491: ...nk htm in the application folder Configuration Objects Common Notice that the head tag of the file contains the following lines script language javascript src Shared Common Scripts ListControlClass js...

Page 492: ...492 The Shared Folder...

Page 493: ...312 applyFormat 403 applyFormatDefinition 403 applySB 336 applyServerBehavior 330 applyTag 276 appName property 135 appVersion property 135 arguments passed from menuitem 196 receiveArguments 212 arg...

Page 494: ...tensibility API JS_BooleanToValue 465 JS_DoubleToValue 465 JS_ExecuteScript 469 JS_GetArrayLength 467 JS_GetElement 468 JS_IntegerToValue 466 JS_NewArrayObject 467 JS_ObjectToValue 466 JS_ObjectType 4...

Page 495: ...description tag 58 function tag 61 menu tag 59 menugroup tag 58 menuitem tag 60 code snippet extensions definition 101 code validation 92 CodeHints xml file contains 56 description of 55 color button...

Page 496: ...data translator extensions definition 101 data translators debugging 442 for attributes 435 for tags or blocks of code 437 kinds of 435 user experience 434 database controls 116 database tree control...

Page 497: ...te 351 openTag 366 paramName attribute 360 paramNames attribute 355 participant 347 partType attribute 346 quickSearch 348 searchPatterns 352 353 363 selectParticipant attribute 344 subType attribute...

Page 498: ...code coloring 73 G generateDynamicDataRef 394 generateDynamicSourceBindings 395 getAttribute 132 getCodeViewDropCode 414 getComponentChildren 412 getContextMenuId 413 getCurrentValue 240 getDockingSid...

Page 499: ...ew 301 isCommandChecked 211 243 isDOMRequired 245 isDomRequired 162 178 isLocked tag code coloring 75 isOptional attribute 357 isResizable 302 item tag 29 item tags in toolbars 226 item 128 itemref ta...

Page 500: ...ENODE 120 MM_ConfigFileExists 473 mm_deleted_files xml file about 28 deleteditems tag 29 item tag 29 tag syntax 29 MM_GetConfigFileAttributes 475 MM_GetConfigFolderList 472 mm_jsapi h file including 4...

Page 501: ...ant files 323 participant tag 347 participants 322 partType attribute 346 password field object 128 pasteServerBehavior 334 processFile 256 Property inspector API canInspectSelection 285 displayHelp 2...

Page 502: ...ior 334 server behavior extensions definition 101 server format extensions definition 101 Server Formats API applyFormat 403 applyFormatDefinition 403 deleteFormat 404 formatDynamicDataRef 405 inspect...

Page 503: ...nsions definition 100 toolbar tag 221 toolbarControls 420 toolbars button tag 226 checkbutton tag 227 colorpicker tag 231 combobox tag 230 command API 238 controls 216 creating 215 docking 217 dropdow...

Page 504: ...ine 279 W W3C 128 whereToSearch attribute 364 width attribute 234 window object 128 window close 128 windowDimensions in behavior actions 320 in Commands API 178 in menu commands 213 in Objects API 16...

Reviews: