Adobe GoLive CS2 Programmer's Manual
Adobe GoLive CS2 Programmer's Manual

Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

Quick Links

SDK Programmer's Guide

Advertisement

Table of Contents
loading

Summary of Contents for Adobe GoLive CS2

  • Page 1 SDK Programmer’s Guide...
  • Page 2 Macintosh NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of Adobe Systems Incorporated.
  • Page 3: Table Of Contents

    Contents Preface ............................10 About Adobe GoLive CS2 SDK ..............................10 About This Book....................................11 Who should read this book ..............................11 What is in this book ................................11 Document conventions ...............................12 Typographical conventions ............................12 JavaScript common properties...........................12 Where to Go for More Information ............................13 Installing and Configuring the GoLive SDK................
  • Page 4 Adobe GoLive CS2 SDK SDK Programmer’s Guide Contents Nesting Event Handlers ...............................34 Sharing Data....................................34 Persistent shared data................................35 Non-persistent shared data..............................35 Communicating with other extensions .........................35 Sending messages to other extension modules ....................36 Responding to a broadcast ............................36 Delays and Timeouts...................................36 Timed tasks....................................37...
  • Page 5: Sdk Programmer's Guide

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Creating tab panels ................................63 Creating split panels ................................64 Autolayout of Localized Controls ............................65 Adding Controls to Windows..............................66 Creating different types of controls ..........................67 Creating radio button groups .............................68 Creating text input fields ..............................68 Creating source and preview controls ........................69...
  • Page 6 Adobe GoLive CS2 SDK SDK Programmer’s Guide Implementing the undoSignal Function........................90 Updating Images Dynamically ..............................91 Creating pictures..................................92 Drawing the image................................92 Deleting pictures..................................93 Editing Documents Programmatically..................94 The GoLive Document Object Model ..........................94 The Markup Tree...................................94 Reparsing and object references .............................95 Markup editing options..............................95...
  • Page 7: Sdk Programmer's Guide

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing existing styles and stylesets..........................117 Inserting Elements in Layout View............................117 Inserting raw HTML ................................118 Working with Tables in Layout View ..........................118 Table styles .................................... 118 Applying a table style within a table ........................119 Table cells....................................
  • Page 8 Adobe GoLive CS2 SDK SDK Programmer’s Guide Creating custom columns in the Site window ......................139 Using event handlers to display custom column content................140 Using named properties to display custom column content............... 140 Removing a custom column at runtime....................... 141 Working With Site Documents .............................
  • Page 9 Adobe GoLive CS2 SDK SDK Programmer’s Guide Installing an external JavaScript library........................ 179 Installing Binary Libraries............................179 External JavaScript Libraries ..............................179 Including an external JavaScript file ..........................180 Calling JavaScript library functions ..........................180 External Binary Libraries ................................. 181 Implementing external binary libraries ........................
  • Page 10: Preface

    The Adobe GoLive CS2 SDK (Software Development Kit) enables you to extend the behavior and user interface of GoLive CS2. Using the GoLive CS2 SDK, you can create tools tailored to your specific GoLive tasks. The SDK can create, customize, and extend most aspects of the GoLive user interface, such as: Menus and menu items ●...
  • Page 11: About This Book

    This book is for anyone who wants to extend the capabilities of Adobe GoLive using JavaScript and the special markup tags that the GoLive CS2 SDK provides. This book assumes that: You know how to create pages and Web sites in Adobe GoLive, as described in the Adobe GoLive CS2 ●...
  • Page 12: Document Conventions

    JavaScript common properties Because most objects provided by the SDK provide a name property, the Objects chapter in the GoLive CS2 SDK Programmer’s Reference (companion volume to this guide), does not list name properties explicitly. Similarly, the Reference does not list properties and methods provided by the JavaScript language itself.
  • Page 13: Where To Go For More Information

    JavaScript implementation. Where to Go for More Information This book documents the Adobe GoLive CS2 SDK only. It does not describe the JavaScript language or how to use the GoLive CS2 application. For documentation of the JavaScript language or descriptions of how to use it, see any of numerous works on this subject, including the following: JavaScript: The Definitive Guide, 4th Edition;...
  • Page 14: Installing And Configuring The Golive Sdk

    Installing the core set of tools and sample extensions This section describes how to install an extension in GoLive. GoLive CS2 SDK files are initially installed in a subfolder of the Adobe application folder called Adobe GoLive SDK 8.0r1 . The extensions provided with the SDK are in the Samples and Tools folders.
  • Page 15: Uninstalling An Extension

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Installing and Configuring the GoLive SDK 4. Copy the following folders from the GoLiveSDK_dir/Tools folder to the GoLive_dir/Modules/Extend Scripts folder: Dialog Editor ● Edit Extension ● Extension Builder ● 5. Start GoLive. When GoLive starts, it loads all of the extensions present in the Extend Scripts folder.
  • Page 16: Enabling And Disabling Modules

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Installing and Configuring the GoLive SDK 3. In the list of modules, check the Extend Script module. ExtendScript module checked Show description of selected module 4. Click OK to confirm your changes and dismiss the Preferences panel.
  • Page 17: Debugging Your Scripts

    Scripts.” ● The ExtendScript Toolkit is described in Chapter 5, “ExtendScript Tools and Features,” of the GoLive CS2 ● SDK Programmer’s Reference. These tools are complete development environments that allow you do more than just test your code— you can use them, for example, to edit documents interactively. To become familiar with the JavaScript environment in GoLive, try entering some JavaScript expressions into the Command field of a Debugger window;...
  • Page 18: How To Create An Extension

    About Adobe GoLive CS2 Extensions An extension that you create for Adobe GoLive CS2 using the SDK is actually an HTML file that GoLive uses in a special way. Creating an extension is similar to creating a web page: you add tags and scripts to this file to define content.
  • Page 19: Anatomy Of An Extension

    GoLive document window, just like any other markup document. GoLive CS2 SDK provides enhanced support for site-level operations, including notification of changes in the content or organization of the Site window, and programmatic selection of site assets according to criteria you specify.
  • Page 20: Extension-Building Tools

    GoLive calls your extension’s handler for that event. Extension-building tools The GoLive CS2 SDK includes powerful tools that make extension building easy. These tools are found in the GoLiveSDK_dir /Tools folder. To use them, copy them into the GoLive_dir /Modules/Extend...
  • Page 21: Example Main.html File

    Extend Scripts folder. This section describes how to create the file and folder structure GoLive expects extensions to have. To begin creating an extension, first create the extension folder. Create a folder with a unique name and place it in the Adobe GoLive CS_ Lang /Modules/Extend Scripts/ folder.
  • Page 22: Creating The Main.html File

    How to Create an Extension In this folder, create a new file named Main.html . You can use any text or HTML editor to edit this file, including Adobe GoLive CS2 itself. Creating the Main.html file The Main.html file contains the markup tags and JavaScript that define an extension.
  • Page 23: Adding Sdk Tags And Javascript Functions To The Module

    ” Congratulations! You have just created your first extension to GoLive. That is really all there is to creating a basic extension using the GoLive CS2 SDK. Adding SDK Tags and JavaScript Functions to the Module This section illustrates some development techniques by walking you through a simple extension that writes a message in the JavaScript Debugger window and displays a user alert.
  • Page 24: Adding The Module Tag

    The GoLive CS2 SDK Programmer’s Reference provides the names and syntax of all the event and event target objects, and describes the handlers that you can define. Most of them are optional; you only need to supply handlers for the events you need to respond to.
  • Page 25 Adobe GoLive CS2 SDK Programmer’s Guide How to Create an Extension The following example shows very simple implementations of the initializeModule , startModule , and terminateModule functions. // Main.html file for Hello example <html> <body> <jsxmodule name="HelloModule" debug> <script> // functions that provide your extension’s behavior go here function initializeModule() { writeln ("Loading the "...
  • Page 26: Summary

    The next several chapters of this book describe how to add tags that create menus, dialogs, and ● custom markup elements in the GoLive environment. For a complete list and description of the GoLive CS2 SDK objects, functions, and properties, see ● Chapter 1, “Objects,”...
  • Page 27: The Javascript Environment

    GoLive passes relevant objects as event-object property values to event-handling functions. ● For information on retrieving a particular object, see that object’s description in the GoLive CS2 SDK Programmer’s Reference. Accessing attribute values The attributes of an element (whether it is a document markup element or an element in your extension definition) appear as the properties of the corresponding JavaScript object.
  • Page 28: Naming Objects And Attributes

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment attribute of the element becomes the name property of the object. Access to JavaScript properties is case-sensitive; that is, the Thing attribute creates the Thing property, not the thing property. When writing JavaScript code, observe case accordingly.
  • Page 29: Javascript Object Collections

    These examples use the menus array to illustrate how you retrieve objects from global arrays. This array provides access to all of the menus and menu items added to GoLive by extensions. Most of the arrays work the same way; exceptions are noted in the GoLive CS2 SDK Programmer’s Reference.
  • Page 30: Comparing Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment The following JavaScript defines a menu Sample , with one item, MyItem . The SDK creates a menu object named sample and a menuitem object named item1 : <jsxmenu name="sample" title="Sample" ...>...
  • Page 31: Scope Of Variables And Functions

    For a complete listing and description, see Appendix E, “Scoping in JavaScript in the GoLive CS2 SDK Programmer’s Reference. To demonstrate variable scope in the JavaScript Debugger window, add the following highlighted lines to the Main.html file that you created in Chapter 2, “How to Create an...
  • Page 32: Releasing Memory

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment To set the global variable, type the following into the command line: myGlobal = "Hartford, Hereford, and Hampshire." Then run the function from the command line: fabFour(); The function prints the changed string to the output window, using the new value of the global variable.
  • Page 33: Defining And Registering Event Handlers

    Elements"). For a complete list of events and the circumstances that generate them, see Chapter 3, “Events and Event Handlers" in the GoLive CS2 SDK Programmer’s Reference. Note: Event handling has changed significantly in this release. See Compatibility with Previous Event Handlers in the GoLive CS2 SDK Programmer’s Reference.
  • Page 34: Nesting Event Handlers

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment doThisHandler) It is not necessary to unregister handlers on termination; the shutdown process does so automatically. To unregister a handler before termination, use the target object’s function. removeEventListener Nesting Event Handlers...
  • Page 35: Persistent Shared Data

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment Persistent shared data Extensions can create their own preference data which persists across between user sessions and is available to all extension modules. This feature enables all extensions to share a common set of preferences and to store persistent data.
  • Page 36: Sending Messages To Other Extension Modules

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment Sending messages to other extension modules The broadcast method sends its argument to the broadcastSignal method of any or all running extension modules. argument targets broadcast( This method converts the argument value to a string, stores the name of the calling module and the argument string to a broadcastEvent object, and generates this event in the target module or modules.
  • Page 37: Timed Tasks

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment You can display a progress bar or busy bar to the user while your extension performs lengthy ● processing tasks. Timed tasks You can evaluate a JavaScript expression after a specified delay. The startTimer global function accepts a scriptlet and a timeout.
  • Page 38: Starting A Progress Or Busy Bar

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment A busy bar does not display a progress value; instead, it rotates the spiral indicator about once a second. For example: app.startProgress( 'Please wait', 'Processing', true); //busy bar These are the same dialogs GoLive displays as part of its own user interface. Three methods of the...
  • Page 39: Progress Bar Example

    Adobe GoLive CS2 SDK SDK Programmer’s Guide The JavaScript Environment The optional message argument is the string to display as the new status message. You can update a ● busy bar with a new status message; it ignores the value argument.
  • Page 40: Menus And Toolbars

    Menus and Toolbars This chapter describes how you can use the GoLive CS2 SDK to add menus and menu items to the GoLive menu bar and context menus, and add toolbars to the GoLive main toolbar. Note: This chapter does not describe pop-up menus, which are controls that appear in dialog windows.
  • Page 41: Adding The Menu Bar Tag

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars <jsxmenu name="Hello" title="Hello, GoLive!"> // custom menu <jsxitem name="doThis" title="Do Something"> // menu item 1 <jsxitem name="doThat" title="Do Something Else" > //menu item 2 </jsxmenu> // closes definition of Hello menu </jsxmenubar>...
  • Page 42: Defining Menu Items

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars The name attribute specifies the name used to access the menu in the JavaScript namespace, while the title attribute specifies the text that appears as the menu’s title in the GoLive menu bar.
  • Page 43: Creating Submenus

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars </html> These menu items appear in the menu in the same order that their definitions appear in the <jsxmenu> element. Creating submenus A submenu is an item in a menu that cascades into another menu. To define a submenu, use the <jsxmenu>...
  • Page 44: Using One Handler To React To Multiple Items

    For details of how multiple handlers are executed when an event fires, see How registered event-handlers are called in the GoLive CS2 SDK Programmer’s Reference.
  • Page 45: Complete Simple Menu Example

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars Complete simple menu example Here is the complete Main.html file that defines a working menu. Hello, GoLive! // Main.html file for Hello example <html> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"> <meta name="generator" content="Adobe GoLive 6">...
  • Page 46: Setting A Menu Item's State Programmatically

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars "shift+alt" "control+shift+alt" You cannot, however, specify only alt or only shift . The value "control" assigns the C key in WIndows, and the C key in MacOS. The value "alt"...
  • Page 47: Initializing Menu Items

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars are enabled by default. You do not need to set enabled to true unless you have previously disabled the item. This figure show an enabled menu item, which is drawn in black and can be chosen by the user, and a disabled menu item, which is drawn in gray and cannot be chosen by the user.
  • Page 48: Adding Items To Golive Menus

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars The setColorMenu function for the extension that defines these menu items sets the enabled and checked states of each menu item, according to whether the current document’s background color is red, green, or some other color.
  • Page 49 Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars To add your own menu items to an existing menu, place your <jsxitem> tags inside a <jsxmenu> element whose name attribute has that menu’s name. Your script can access all existing menus by name from the global app.menubar array.
  • Page 50: Extending Context Menus

    GoLive CS2 SDK Programmer’s Reference. Extending Context Menus The GoLive CS2 SDK provides limited access to some of GoLive’s context menus, through the context menu events. These events are triggered when the user opens or makes a selection in the context menu.
  • Page 51: Registering Context Menu Handlers

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars Event Generated for: The Open submenu of the context menu for files listed in the Site cmSiteSubOpen window. The Publish Server submenu of the context menu for the Site cmSiteSubPublish window.
  • Page 52: Creating Toolbars

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars function( cmEvt ) { switch( cmEvt.action ) { case 'extend': { cmEvt.menu.addChild( 'item', 'TestItem', 'TestItem', true ); var sm = cmEvt.menu.addChild( 'menu', 'TestMenu', 'TestMenu', true ); sm.addChild( 'item', 'Sub1' );...
  • Page 53 Adobe GoLive CS2 SDK SDK Programmer’s Guide Menus and Toolbars You cannot create toolbars programmatically, and you cannot access the toolbar’s window object through the Window.find method. The toolbar windows are, however, in the dialogs list, and can be accessed by name.
  • Page 54: Windows And Controls

    Windows and Controls This chapter describes the different types of windows and how to create them, how to add various kinds of controls to the windows, and how to define the behavior of the controls. Types of Windows The SDK window Object represents windows that you create in extensions, and also gives you access to GoLive windows.
  • Page 55: Using The Dialog Editor Tool

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls The frameBounds property of the Inspector window is read-only. When the Inspector window is inactive, the dimension values are all zero. For other kinds of dialogs, assigning a new bounds object to this property sets the associated dialog window’s size and location.
  • Page 56 Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls 4. Begin by creating a layout grid that will contain the other controls in the dialog. Drag the Layout Grid palette entry onto the GoLive document window. A Layout Grid object appears.
  • Page 57 Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Static Text object Checkbox object Note: Controls dropped on a layout grid are implemented as table elements. Such controls ignore the width and height attributes their enclosing dialog specifies. Instead, they use the table’s width and height attributes as the size of their enclosing container.
  • Page 58: Modal Dialog Windows

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Modal Dialog Windows This section describes how to define a modal dialog window, add controls to it, display it, and interpret the returned values. Defining the modal dialog window The <jsxdialog> element defines a modal dialog window. Other tags define the window content, such as text and buttons.
  • Page 59 Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls After the dialog closes, all of its control objects remain available in the JavaScript namespace, and you can continue to access their property values. The following example shows two ways to use the show function’s return value.
  • Page 60: Closing A Modal Dialog

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Closing a modal dialog To close a modal dialog window, you must add one or more controls that can dismiss it. There are two ways to dismiss a dialog: Any control created with a name attribute of dialogok , dialogcancel , or dialogother closes the ●...
  • Page 61: Showing And Hiding Palettes

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls A <jsxpalette> element has this syntax: objectName TitleOfPalette <jsxpalette name=" " title=" " NumOfPixels NumOfPixels width=" " height=" " > // for controls, add <jsxcontrol> elements here // for palette menu, add <jsxmenu> and <jsxitem> elements here </jsxpalette>...
  • Page 62: The Inspector Window

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls // assume we created <jsxpalette name="myPalette" ... > // get myPalette from the global dialogs array var dlg = dialogs["myPalette"]; // show it if its hidden if (dlg.visible == false) dlg.visible = true;...
  • Page 63: Control Containers

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Control Containers A window can use containers called panels, to group controls. You can define reusable groups of controls, called panel resources. You can define tabbed panels, such as those in a palette, and split panels that contain exactly two subpanels with a movable boundary line.
  • Page 64: Creating Split Panels

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls <jsxtabview posx="10" posy="9" width="235" height="136"> <jsxview resource="tabpanel1" name="tabpanel1" height="84" width="201"> <jsxview resource="tabpanel2" name="tabpanel2" height="84" width="201"> <jsxview resource="tabpanel3" name="tabpanel3" height="84" width="201"> </jsxtabview> </jsxdialog> The tab panel is represented in GoLive by the JavaScript tabpanel Object.
  • Page 65: Autolayout Of Localized Controls

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Autolayout of Localized Controls GoLive translates UI strings to the language for the current locale of the computer it is running on. For details, see Dynamic UI Localization. Because the length of the string can be different in different languages, this can affect the appearance of your control layout.
  • Page 66: Adding Controls To Windows

    For a complete list of allowed types, see the GoLive CS2 SDK Programmer’s Reference. In addition to the control types provided by the SDK, you can create custom controls; see Creating ●...
  • Page 67: Creating Different Types Of Controls

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Creating different types of controls This example illustrates the use of the <jsxcontrol> tag to create the controls shown in this dialog box: A sample dialog with various control types type="checkbox"...
  • Page 68: Creating Radio Button Groups

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls <jsxcontrol type="static" name="bunPrompt" value="Which kind of bread?" posx="10" posy="110" width="300" height="18"> <jsxcontrol type="popup" name="breadMenu" value="Baguette, Pita, Rye, Sourdough, Wheat" posx="10" posy="135" width="90" height="18"> <jsxcontrol type="edit" name="custNameField" value="signal whenever focus changes" posx="10" posy="170" width="150" height="18">...
  • Page 69: Creating Source And Preview Controls

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls by defining an onChange event handler; the exact action that triggers the event depends on the type of the control and its property values. See ‘Handling editing actions’ on page...
  • Page 70: List Controls

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls <jsxparam name="min" value="0"> <jsxparam name="max" value="10"> <jsxparam name="steps" value="10"> </jsxcontrol> List controls List controls contains an items property, which contains an array of item objects. Each list item is a control of type item (or in some cases node ) that represents a selectable choice in the list.
  • Page 71 Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls </jsxcontrol> Creating hierarchies and file lists This extension file defines a split panel that contains both a file list and a hierarchy. Both are created from a list of folders and their contained files. An event handler performs the expansion of nodes in the hierarchy control.
  • Page 72: Adding Controls To A Window Dynamically

    Object. You create a dynamic control by calling the parent’s function with a set of parameters appropriate to the control type. For information on the complete range of controls that you can create dynamically, see the GoLive CS2 ● SDK Programmer’s Reference.
  • Page 73: Providing Behavior For Controls

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Providing Behavior for Controls If you need to respond to changes in the state of a control object while a modal dialog or palette window is displayed, you can define and register an event handler for the appropriate event in that object.
  • Page 74: Handling Editing Actions

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls coordinates of where the event occurred, and a mode value to indicate which specific mouse action occurred: 0: Mouse button was pressed. 1: Mouse moved while the button was pressed.
  • Page 75 Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls handler that is registered with the target object itself. After executing the target handler, it "bubbles" back out through the ancestor objects, running the first registered handler that it finds on the way out.
  • Page 76: Creating Custom Controls

    For details of how multiple handlers are executed when an event fires, see How registered event-handlers are called in the GoLive CS2 SDK Programmer’s Reference. Creating Custom Controls You can code custom controls entirely in JavaScript. Create a custom control using the tag <jsxcontrol type="custom"...
  • Page 77: Updating A Control's Appearance Immediately

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Windows and Controls Updating a control’s appearance immediately If you need to draw the appearance of a custom control outside the context of the paintEvent handler, you can obtain a temporary draw object by calling the control’s beginDraw function.
  • Page 78: Custom Elements

    GoLive has other built-in ways of creating or inserting HTML code in a page, such as templates and snippets; see the Adobe GoLive CS2 User’s Guide for details. This chapter describes the steps required to create a custom element and add it to the Objects palette: Define the custom element with its custom tag;...
  • Page 79: Defining A Custom Element

    For example, if you specify type="head" , when the user drops this element into a page, it adds its content to the head section of that page. For a complete list valid types, see the GoLive CS2 SDK Programmer’s Reference. The following example defines the <mytag> tag: <jsxelement tagName="mytag"...
  • Page 80: Defining The Custom Tag's Palette Icon And Html Content

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements For example, the following code creates a new <img> element that GoLive uses only in a WML document: <jsxelement tagname="img" glue="wml"> When no glue attribute is present, this element replaces the img element application-wide.
  • Page 81: Creating A Palette Entry In The Objects Palette

    (For a listing of all order values used by the built-in palette icons, see Appendix A, “Object Palette Sort Order in the GoLive CS2 SDK Programmer’s Reference.) The value of your order attribute places it with respect to the existing group or groups in the tab; a smaller value places all the entries in this group before (that is, to the left of) an existing entry group, while a higher value places your group to the right.
  • Page 82: Adding Palette Entries To A Customized Tab

    Appendix A, “Object Palette Sort Order in the GoLive CS2 SDK Programmer’s Reference. When you add entries to a custom object type, the entries appear in the order in which they are defined; if you supply an order attribute, it is ignored.
  • Page 83: Initializing A Custom Element Box

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements You can provide event handlers to respond to various user-interaction events for your custom element: Event Triggering action Description parseBox The document is Register handler with the object. document reparsed: for example,...
  • Page 84: Displaying A Custom Element Box

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements To initialize the custom box, GoLive calls the parseBox handler you have registered for the document object, or for the app object (to capture the event at the top level). For example, the handler might set the box’s height and width as specified by the height and width attributes of the custom HTML element.
  • Page 85 Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements // define the drawBox handler to create visual representation of box function drawMyBox(paintEvt) { var box = paintEvt.target; var drawObj = paintEvt.draw; if (box.element.color != undefined) drawObj.setColor(box.element.color); else // paint a white background and frame it in black, before...
  • Page 86: Resizing A Custom Element Box

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements Resizing a custom element box When the user resizes the box associated with a custom element, GoLive calls the boxEvent handler registered with the box object. Your handler validates the new height and width values as needed by your extension, and sets the attributes of the custom element accordingly.
  • Page 87: Initializing The Inspector Window

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements Set the classid attribute to the same value used by the <jsxelement> and <jsxpaletteentry> ● tags for the custom element this window inspects. Here is a very simple example of the use of the <jsxinspector> element (taken from the Custom Box sample extension, which defines only one control: <jsxinspector name="inspector"...
  • Page 88: Multiple Inspectors

    For a complete list of elements that can be changed without reparsing, see Appendix C, “Managed Layout Tags in the GoLive CS2 SDK Programmer’s Reference. Most operations involving non-SDK elements cannot be undone, because they do cause reparsing. ●...
  • Page 89: The Document's Undo History

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements The document’s undo history The document.history property returns a document.history Object you can use to inspect or manipulate the active document’s undo/redo history. You can set the history list’s index property to cause GoLive to execute any undo or redo actions necessary to restore the document to any state in the history.
  • Page 90: Implementing The Undosignal Function

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements undo.box = box.name; undo.oldSrc = box.element.src; undo.newSrc = box.link.url; // this causes undoSignal() to be called undo.submit(); // register handler with urlgetter control function initializeModule() { var urlgetter = controls[mycontrolname]; urlgetter.addEventListener( 'onChange', urlChanged);...
  • Page 91: Updating Images Dynamically

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements switch (undoEvt.undo.kind) { case "Link": undoLink (undoEvt.undo, undoEvt.action); break; // assume we’ve created these additional undo actions case "TextColor": undoTextColor (undoEvt.undo, undoEvt.action); break; case "What": undoSomethingElse (undoEvt.undo, undoEvt.action); break; //register the handler with the module object function initializeModule() { var myModule = modules[mymodulename];...
  • Page 92: Creating Pictures

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements Creating pictures To create a new picture object, call the global function, passing as its argument the createPicture URL to an image file: myPict = createPicture (Images/myImage.jpg) Your drawBox or other event handler can create picture objects on demand and store them as the properties of the placeholder box of your custom element.
  • Page 93: Deleting Pictures

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Custom Elements draw.frameRect(1, 1, box.width-2, box.height-2); // draw current image, created in parseBox() box.myPict.width = box.width; box.myPict.height = box.height; box.myPict.draw(1,1); //offset by one pixel //register the handler with the box object function initializeModule() { var myBox = boxes[myboxname];...
  • Page 94: Editing Documents Programmatically

    Layout. The Markup Tree The GoLive CS2 SDK allows you to edit HTML and other markup documents interactively in many ways. The SDK allows your extension to make the same kinds of changes programmatically, using SDK objects and their JavaScript functions.
  • Page 95: Reparsing And Object References

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically The document’s markup tree has the same structure: the object for the <html> element is the parent of the head and body objects. The object for the <body> element might have, for example, a header ruler and paragraph elements as its children.
  • Page 96: Automatic And Explicit Reparsing

    Perform operations that cause GoLive to reparse the document. ● Call the reparse method. ● Call the setInnerHTML or setOuterHTML functions if doing so will cause GoLive to reparse the ● document. For more information, see the technical notes and support information at http://partners.adobe.com/asn.
  • Page 97: Working With Documents

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically Working With Documents You can use the functions and properties of the document object to perform basic document operations such as creating, opening, and saving the documents displayed in GoLive’s document windows.
  • Page 98: Display Layout View

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically var fileObj = fileGetDialog(); if (fileObj) fileObj.openDocument(); Display layout view The SDK operates only in Layout view. Before manipulating the contents of a document window programmatically, be sure the window is displaying Layout view.
  • Page 99: Validate Document Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically if (documents.length > 1) Window.alert("Make sure only one document is open and try again."); return; // otherwise, process documents here Validate document objects The frontmost window can display various kinds of documents. A document object can represent a markup document, a site document, or some other kind of document.
  • Page 100: Saving Documents

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically Saving documents To save a document, call the document object’s save saveAs method. For example, this saves the contents of the frontmost document: document.save(); If the document has not been saved before, GoLive displays a dialog box in which to specify a file name and the location.
  • Page 101: Retrieving The Current Selection

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically A portion of the current markup element is selected, such as when only part of a text part element is selected. An entire markup element is selected, such as when the user clicks an image box.
  • Page 102: Setting The Current Selection

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically Property Value Description The markup object that holds selection represents an element element created by the tag and attributes in the text property. The entire element is selected. type full Start of selection is not offset from beginning of element.
  • Page 103 Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically <body><h1>Title</h1><p>abcd xyz</p></body> Range 1 Range 2 body “abcd xyz” “Title” Range 1 Range 2 Range 1 is a complex selection that spans two text elements, with part of each in the selection, while Range 2 is a full selection of one markup element.
  • Page 104: Accessing Selections Through The Document Source

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically In this case, not only are the range values of range_c the same as those of range_a , the two variables actually refer to the same range object. Changes made to the properties of variable range_a are also made to those properties of variable range_c .
  • Page 105: Retrieving Individual Markup Objects

    <jsxelement> . The "plain" , "binary" and "container" types search for HTML or XML tags; for a complete list of types, see the GoLive CS2 SDK Programmer’s Reference. For example, to search for the first comment tag in a document: document.getSubElement ("", 0, "!—");...
  • Page 106: Retrieving Multiple Markup Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically Retrieving multiple markup objects The getSubElement method returns only one node at a time. To retrieve every instance of a particular type of node from a document using this function, for example, you would have to call getSubElement repeatedly, add each node to an array, and then process each item in the array.
  • Page 107: Overriding Document Encoding For Elements

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing Documents Programmatically Unary Binary Binary (no optional end tag) Element <img src="Images/ducky.jpg"> <H1>Hello</H1> <LI>first Inner HTML img src="Images/ducky.jpg" Hello first Outer HTML <img src="Images/ducky.jpg"> <H1>Hello</H1> <LI>first The setOuterHTML method replaces an entire element with the provided text. Changes are reflected in the document’s HTML source code buffer immediately, but they may not be realized in the markup or...
  • Page 108: Editing With Layout

    Editing with Layout This chapter describes how to use the layout objects to work with a document’s contents programmatically while Layout view is open. The box , layout , and textArea objects provide methods that minimize the necessity for reparsing and display your changes in the Layout view with a minimum of delay and refresh flicker.
  • Page 109: Editing Displayed Elements Through Layout Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Editing displayed elements through layout objects layout Object, like the box object, manages the appearance of certain HTML elements in Layout view. It can read and write certain of the element’s HTML source attributes without reparsing the document.
  • Page 110: Example: Using Layout Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout The width value in the table layout object’s Inspector window displays the new value. ● You can undo and redo this action in the History window. ● Even in a managed element, not all attributes are managed in this way. The setAttribute method works only on the elements and attributes listed in Appendix C, “Managed Layout...
  • Page 111: Editing Displayed Elements Through Markup Objects

    Call the setInnerHTML or setOuterHTML functions if doing so will cause GoLive to reparse the ● document. For more information on the conditions that cause GoLive to reparse, see the technical note on automatic reparsing in the Developer Knowledgebase at http://partners.adobe.com/asn.
  • Page 112: Editing Text In Layout View

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Editing Text in Layout View textArea Object represents the appearance of text in GoLive’s Layout view; it does not directly represent the document content—that is, the source code of your document. A textArea interprets the content of markup objects, which in turn directly represent the document’s content.
  • Page 113: Manipulating Text Elements

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout When you access a textArea object, GoLive checks whether the document needs reparsing—that is, whether there has been a structural change in the markup tree since the last time the document was parsed.
  • Page 114: Finding And Replacing Text

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Pass the setCursorParagraph method the paragraph number of the cursor’s new position: document.mainTextArea.setCursorParagraph(0); // beginning of first pgf Finding and replacing text The textArea object’s method searches for occurrences of a literal text string or of a string findString that matches a regular expression.
  • Page 115: Manipulating Text Styles

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout The deselect method resets the current selection to none and leaves the cursor positioned at the character offset that marked the beginning of the last selection. Manipulating Text Styles Styles and style sets can come from a number of places: documents can define styles inline in HTML source, CSS style sheets can provide them, other extensions can make them available, and the user can create them in the Window >...
  • Page 116: Applying Styles To Selected Text

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout The Advanced tab lists each single style ( HTMLStyle ) in the style set ( HTMLStyleSet ) being edited. The Name column shows the single style element each HTMLStyle object represents.
  • Page 117: Editing Existing Styles And Stylesets

    To insert a built-in element, pass the identifying keyword, such as table . For a complete listing of ● supported elements and keywords, see in the GoLive CS2 SDK Programmer’s Reference. insertBox To insert a custom element, pass its classid value; see Chapter 6, “Custom...
  • Page 118: Inserting Raw Html

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Inserting raw HTML The insertHTML method adds any raw HTML source to the document as HTML. For example, a database-driven site that builds an HTML page dynamically would use this method to insert its custom HTML output into a page.
  • Page 119: Applying A Table Style Within A Table

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout property holds a collection of table-style objects for every available table style. app.tableStyles This example applies one of these styles to a <table> element: // get the table layout object var table = document.documentElement.getSubElement("table").layout.table;...
  • Page 120: Cell Styles

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout // set the size table.cell[i].width = 150; table.cell[i].height = 150; // set alignment of the embedded image table.cell[i].textArea.selectAll(); table.cell[i].textArea.applyStyle("div align=center"); The tableCell object contains a textArea Object, that you use to modify the cell’s contents. For example, this inserts an <img>...
  • Page 121: Working With Layout Grids

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Working with Layout Grids layout.grid Object represents a Layout Grid in Layout view. You can get the grid object from the document object’s layout object: document.layout.grid Use this object to set up and optimize the Layout Grid programmatically, as you do with the Layout Grid’s Inspector window and its Optimize command.
  • Page 122 Adobe GoLive CS2 SDK SDK Programmer’s Guide Editing with Layout Retrieve the gridLayout object from the markup object that represents the HTML source element it edits: markupObj .layout.gridLayout This example gets an <img> element that has been placed on a grid, then uses its gridLayout methods to set its size, position, and alignment: myImg = document.documentElement.getSubElement("img");...
  • Page 123: Managing Files And Folders

    Managing Files and Folders This chapter describes how to manipulate files and folders associated with GoLive documents on local and remote file systems. The webSite object offers additional capabilities for dealing with files associated with a web site; see Chapter 10, “Managing Web Sites.
  • Page 124: Acquiring File Objects

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders disk-based entity it represents; the object simply holds the pathname to one file or folder. Its methods operate on that file or folder if it is available at the specified location. The file object issues requests to a local or remote file system that actually does the work.
  • Page 125: Accessing Folders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders been deleted or moved, or may never have been created. The isFile property is similar. If there is neither a file nor a folder at the specified location, both properties are false .
  • Page 126: Getting A File Object From The User

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders Property Type Description Site The root folder of the site for a document that does not document.ref.siteDoc.site Reference represent a Site window (for a markup document, for example). Site The site’s home page for a document that does not...
  • Page 127: Moving, Copying, And Deleting Files And Folders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders file = JSXFile ("Main.html"); Specifying the path as a URL allows you to avoid dealing with most platform-specific file-naming conventions. You need not construct different versions of the same pathname using platform-specific separator characters.
  • Page 128: Moving And Copying Folders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders Moving and copying folders The copy method of the file object cannot copy a folder. To copy a folder’s contents, you must copy individual files into your own destination folder.
  • Page 129: Reading The Contents Of An Existing File

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders You can also use the website Object to create a new HTML file as part of a web site; see Creating Files and Folders in GoLive Web Sites. Like document files create from the app object, these files must be saved before they exist on disk.
  • Page 130: Working With Folders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders Working With Folders When the files you are working with are not part of a GoLive site, you can use file objects to create and manipulate folders. If the files are part of a web site, the webSite object offers higher-level options; see Chapter 10, “Managing Web...
  • Page 131: Getting Files From A Sitereference Object

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders To retrieve only references to subfolders, not files, pass “fldr” as the second, optional type argument: ● var theFolders = theDir.getFiles("*", "fldr"); Use the first optional mask argument to retrieve standard file types, or files and folders whose names ●...
  • Page 132: Retrieving The Contents Of Subfolders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders Retrieving the contents of subfolders The getFiles method operates only in the folder that the called siteReference or file object represents. To retrieve the contents of a subfolder, you must write your own code that calls the getFiles method of the object that represents the subfolder.
  • Page 133: Working With Remote Files

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders return result; For a folder, the processOneFolder function passes the folder back to the top of the getFolderContents method, which gets its contents and dispatches the siteReference objects to the helper functions.
  • Page 134: Exchanging Data With Remote Hosts

    // send a HTTP GET request conn.write ("GET /index.html HTTP/1.0\n\n); // read the server's reply reply = conn.read(); conn.close(); After executing this code, the variable reply contains the contents of the Adobe home page together with an HTTP response header.
  • Page 135: Establishing An Internet Server

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders Establishing an internet server To establishing an Internet server, your socket object must connect to a specific local port, using the listen method, then check periodically for incoming connections on that port using the poll method.
  • Page 136 Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Files and Folders connection.close(); delete connection; writeln ("Connection closed"); function chatClient() { var connection = new Socket; // connect to sample server if (connection.open ("remote-pc.corp.adobe.com:1234")) { // then chat with server chat (connection);...
  • Page 137: Managing Web Sites

    Managing Web Sites The GoLive CS2 SDK provides powerful, customizable tools for organizing and manipulating a web site’s resource files and folders. The Site window allows you to manage a web site interactively. The website Object encapsulates information about a site, and allows extensions to manage sites programmatically.
  • Page 138: Using Templates

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites When the method returns, the Untitled.html file exists on disk and appears in the Site window. The webSite methods that create a file or a folder return a siteReference Object that provides access to the newly created item.
  • Page 139: Deleting Files And Folders

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites Deleting files and folders The webSite object does not provide specific support for deleting files and folders within a site. Remove files or folders using the remove method of the file or siteReference object.
  • Page 140: Using Event Handlers To Display Custom Column Content

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites To create a basic custom column, use the website Object’s addColumn insertColumn method. ● GoLive automatically calls the functions you register in response to events that cause the column to be redisplayed.
  • Page 141: Removing A Custom Column At Runtime

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites Removing a custom column at runtime To remove a custom column at runtime, use the website Object’s removeColumn method. Specify the column to remove by passing its JavaScript name or the ID returned when the column was added or inserted.
  • Page 142: Working With Site Documents

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites Working With Site Documents The Site window lists all of the pages, images, scripts, and other assets that compose a web site. Double-clicking any HTML file in the Site window displays its content in a page-design window.
  • Page 143: Copying Files

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites If the site that uses the document is open, the siteDoc property of this siteReference object holds ● the document object that represents the site. If the site is not open, the siteDoc property is null or undefined.
  • Page 144 Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites You can specify the destination of the copy as a pathname or as a local URL. The following code example uses URLs to copy the newImage.gif file from an installed extension’s folder to the currently open site’s script library folder.
  • Page 145: Working With Version Control Systems

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites // is source file available to copy? if (srcFileObj.exists == false) Window.alert("Can't find source graphic. Must exit."); return false; // copy the source file to the destination URL if(srcFileObj.copy(destURL) == false) Window.alert("The copy operation failed.");...
  • Page 146 SDK Programmer’s Guide Managing Web Sites The GoLive CS2 SDK provides an API you can use to extend this dialog, in order to provide settings for connection to a new version-control system. When an extension provides this connection information, the new system is added to the pop-up list of available systems.
  • Page 147 Adobe GoLive CS2 SDK SDK Programmer’s Guide Managing Web Sites <jsxcontrol type="popup" name="specPopup" posx="10" posy="10" height="20" width="150" halign="scale"/> <jsxcontrol type="button" name="dialogok" posx="60" posy="50" width="50" height="20" value="OK" /> </jsxdialog> The <jsxvcs> tag creates a VCSHandler Object. It is the name of this object that appears as a choice in the Site Settings dialog and the site-creation wizard.
  • Page 148 Your handler retrieves the information or user names. For details of these events, and of the event objects that are passed to handlers, see Chapter 3, “Events and Event Handlers," in the GoLive CS2 SDK Programmer’s Reference.
  • Page 149: Localization And Translation

    This chapter describes localization translation facilities in the GoLive CS2 SDK. The GoLive translation mechanism is a preprocessor that transforms source code according to a translation method that you provide. It is not a human-language translator. The mechanism that translates display strings into different local languages is called localization.
  • Page 150: Creating A Localization Table In Golive

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation // contents of localization table here </table> </jsxlocale> </body> </html> The localization table looks like this: Are you sure? Sind Sie sich sicher? Er du sikker? Search Suchen Start søk...
  • Page 151: Creating An External Localization Table

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation <td>Are you sure?</td> <td>Sind Sie sich sicher?</td> <td>Er du sikker?</td> </tr> <tr> <td>Search</td> <td>Suchen</td> <td>Start s&oslash;k</td> </tr> </table> </jsxlocale> You may need to use special character sequences to express certain characters as HTML. For example, the søk string in the Norwegian column is specified by s&oslash;k in the table’s HTML source.
  • Page 152: Translating Javascript Strings

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation This pushbutton displays as its label when running on a German version of GoLive, but it displays Suchen when running on a Norwegian version of GoLive. If it is running in French, it does not find a Start søk...
  • Page 153: Document Source Translation

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation Document Source Translation translator Object modifies a markup document’s source code before GoLive parses that source to generate the DOM. You can use a translator to: Transform unknown markup elements to a format GoLive can parse, such as XML or HTML.
  • Page 154: Inspecting Translated Elements

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation <param name="expression" value="<include\s*[^>]*>"> </jsxtranslator> The translator must use regular expressions to select text to replace because the DOM is not available to it—translation occurs before GoLive parses the document to generate the DOM.
  • Page 155 Adobe GoLive CS2 SDK SDK Programmer’s Guide Localization and Translation Your handler should translate the code string as required and set the url property of the event object to the new link URL.
  • Page 156: Extending Golive Actions

    GoLive actions are editable and extensible. You can use the predefined actions, or create your own to develop even more powerful custom solutions. This chapter provides information you need to edit or create your own actions. See also the Adobe GoLive CS2 User Guide and the GoLive online help for information on using existing GoLive actions.
  • Page 157: Creating Your Own Actions

    Creating Your Own Actions You can add your own extensions to the predefined actions available from the Action popup in the Actions palette. Actions are defined by HTML files that reside in the Adobe GoLive CS2 SDK application folder, in the Modules\JScripts\Actions subfolder.
  • Page 158: Changing Action Icons

    In the Actions palette, each action has an associated icon, which appears next to its name when you select it from the Action popup list. The Mac OS version of Adobe GoLive CS2 SDK uses the Finder’s icon for the action file as the icon for the ●...
  • Page 159 Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions The action tags define the action object: its name, its associated function, and any parameters that the ● user can specify for it. A script included inline or referenced by the .action file defines the behavior of the action when it is ●...
  • Page 160: Action Tags

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions Action Tags You use special tags to identify an action, to create the parameter controls, and to generate the JavaScript code. These tags are required. Because they are custom tags, they appear as blue rectangles in the layout mode, as shown in the figure.
  • Page 161: Csactionparam

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions csactionparam The <csactionparam> tag can be included in a <csactionclass> tag to define a parameter of the action. You can include any number of parameters. The tag specifies a type of control to be included in the Actions palette when this action is selected.
  • Page 162 Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions Parameter type Description Action Palette Component Checkbox GLActionBoolParam Example: Multimedia\Flip Move.action Color selector GLActionColorParam Example: Others\Set BackColor.action Special control to choose GLActionConditionParam condition actions, which return true false Example: Specials\Condition.action...
  • Page 163: Javascript Source For Actions

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions Parameter type Description Action Palette Component Popup menu that lists all GLActionSceneParam scenes (Timeline) of the current document Example: Multimedia\Play Scene.action Editable text field GLActionStringParam Example: Message\Open Alert Window.action Control to define a URL...
  • Page 164 Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions You can edit this object in the Layout view to further customize the display, providing more information about the action to the end user. You can add static text, informational text, or an image with an associated URL, using the GoLive Layout view of your action’s layout grid.
  • Page 165: Action Tutorials

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions Action Tutorials The following sections guide you through the process of modifying and creating actions. These tutorials show you how to: Customize the action inspector for an existing action. ●...
  • Page 166: Tutorial 2: Go To Previous Page Action

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions In the Inspector for the original “Message” text, change the type from Info Text to Static Text and notice how it changes to bold font in the Layout view. In the Inspector for the new text, leave the type as Info Text and change the name of the message to: “This action brings up an alert box.
  • Page 167: Tutorial 3: Resize Window Action

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions actions so they are well behaved in all browsers. If the script will not work, it should be ignored by the browser and not produce any errors. Since this script won’t require any user input, it won’t need a csactionparam tag. Delete this tag from the page.
  • Page 168 Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions 3. Now define the action class. Double-click on the csactionclass tag to bring up the Inspector and view its attributes. The first attribute is name . In this example, enter “Resize Window” as the value.
  • Page 169 Adobe GoLive CS2 SDK SDK Programmer’s Guide Extending GoLive Actions they don’t generate errors in any browser, this holds true in both platforms. And of course the more browsers your action actually works with the more useful it will be to your end users.
  • Page 170: Debugging Scripts

    JavaScript command line, and the ability to edit live JavaScript objects from within breakpoints. GoLive uses the internal JavaScript Debugger by default. You can set it to use the Adobe ExtendScript Toolkit instead, by setting the property settings.sdk.internalDebugger=false . The Toolkit is described in Chapter 5, “ExtendScript Tools and...
  • Page 171: Using The Javascript Command Shell

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts Using the JavaScript Command Shell The leftmost pane of the JavaScript Debugger window is a JavaScript command shell. It provides a command line you can use to communicate interactively with the JavaScript engine built into GoLive. The Special >...
  • Page 172: Executing Javascript Commands

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts Reload all extensions reloads the JavaScript functions defined in all currently loaded extension ● modules. The currently-defined objects and variables are not affected by this command. This command does not execute any code that is not within a function body. It does not reload static data that is defined in the Main.html file by tags like the <jsxmenu>...
  • Page 173: The Internal Javascript Source Debugger

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts The Internal JavaScript Source Debugger If you have installed any extension that enables debugging, you can open the JavaScript Source Debugger by selecting the checkbox next to the Module selector in the JavaScript Debugger.
  • Page 174: Controlling Code Execution In The Script Debugger Window

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts Turn line numbering on or off ● Controlling code execution in the script Debugger window When the Debugger window is active, the buttons at the top of the Source view control execution, and allow you to set and clear breakpoints in the displayed code.
  • Page 175: Customizing The Debugger Window

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts Customizing the Debugger Window You can control the orientation of the various parts of the JavaScript Debugger window with respect to one another. The figure shows the default configuration, where the Shell and Debugger frames are...
  • Page 176 Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts The infoOrientation property controls the arrangement of the Stack view with respect to the ● Variable view within the Info panel. This figure shows these views arranged horizontally, while the frames and panels are still arranged vertically: Source panel "...
  • Page 177: Troubleshooting Tips

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Debugging Scripts Troubleshooting Tips Null and undefined values The SDK returns null when the object it should return does not exist. The SDK returns undefined to indicate that the accessed property exists but the object it returns does not.
  • Page 178: Using External Libraries

    Using External Libraries Adobe GoLive CS2 SDK extensions can call JavaScript and C functions provided by one or more optional external libraries. Similarly, external JavaScript and C libraries can interoperate with the JavaScript environment GoLive provides. This appendix describes how to create and use external libraries: About External Libraries You can provide function definitions in an external file written in JavaScript, C, or C++.
  • Page 179: Installing External Libraries

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries Installing external libraries There are two possible locations for external library files, depending on whether they are JavaScript or binary. In general: Install JavaScript libraries in the Extend Scripts/Shared folder.
  • Page 180: Including An External Javascript File

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries In your extension, use the src attribute of the <script> tag to import external JavaScript libraries; ● Including an external JavaScript file. Including an external JavaScript file An extension’s JavaScript code appears between <script> and </script> pairs in the Main.html file.
  • Page 181: External Binary Libraries

    GoLiveCS_dir/C Library Samples/include/ folder. For more information on what is included, Appendix D, “C API for External Binary Libraries, in the GoLive CS2 SDK Programmer’s Reference. To make the contents of the include/ subfolder available to your C development environment, add the...
  • Page 182: Initializing The Javascript Engine

    JavaScript as C-language data structures. To extract its arguments from the C-language data structures that encapsulate them, the called function must use the Accessor Functions. For a complete list and syntax details, see the GoLive CS2 SDK Programmer’s Reference. Math function example This is a typical implementation of a mathematical function: #include "JSA.h"...
  • Page 183 Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries void JSAMain() { JSARegisterFunction ("power", power); Drawing function example To implement the drawing of a custom box as compiled code, use the getDrawInfo method of the draw object. This method returns a magic integer number that is passed on to a native code function.
  • Page 184: Registering External Functions

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries Registering external functions All external binaries must implement the JSAMain function as described here. Your implementation of this function must register each of your external library functions with GoLive. To do so, it passes each function’s JavaScript and C-language names to the JSARegisterFunction function.
  • Page 185: Evaluating Javascript Expressions In C Functions

    Functions, and Appendix E, “Scoping in JavaScript in the GoLive CS2 SDK Programmer’s Reference. C functions in external libraries can use the JSAEval function to: Retrieve the values of JavaScript properties from within the scope of the calling module. ●...
  • Page 186: Performance Issues

    Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries To operate on the data passed as the script evaluation’s result, the myExtFn function must extract it from the returnValue pointer in a format that suits your development goals. To do so, pass the returnValue pointer to the JSAValueToXx method that returns your preferred data type.
  • Page 187 Adobe GoLive CS2 SDK SDK Programmer’s Guide Using External Libraries if (diff == 0) writeln ("Both functions executed in the same amount of time."); if (diff > 0) writeln("Compiled code was faster by "+ diff + " milliseconds.") else writeln("Script code was faster by " + (-diff) + " milliseconds.");...
  • Page 188: Glossary

    In the GoLive CS2 SDK, an object that represents a displayed file, such as a markup document. The document object allows you to create new HTML pages, save new or modified documents to files, and access the markup objects hierarchy that represents the document’s contents.
  • Page 189 A script written in ExtendScript that extends the functionality of Adobe GoLive CS2 SDK. extension folder A folder that holds the source files that define one extension. To install an extension, place its extension folder in the GoLive/Modules/Extend Scripts/ folder and restart GoLive.
  • Page 190 Adobe GoLive CS2 SDK SDK Programmer’s Guide Glossary markup document A document that uses a markup language, such as HTML, XML, WML, ASP, or JSP. markup objects A general term for JavaScript objects that represent the contents of a markup document.
  • Page 191 Adobe GoLive CS2 SDK SDK Programmer’s Guide Glossary site folder The folder that holds a site’s .site file and its assets; by default, the site’s root directory. Site window A GoLive window that lists all pages, images, scripts, and external assets that compose a web site.
  • Page 192: Index

    GoLive processes 134 Actions folder 157 communication among modules 34 Actions palette 157 comparisons and case sensitivity 177 Adobe GoLive containers for controls 63 about SDK 10 context menus, extending 50 error handling 17 control interactions 83...
  • Page 193 Adobe GoLive CS2 SDK SDK Programmer’s Guide Index DAV, using to access remote files 133 editing source code with markup objects 106 Debugger window editing text in Layout view 112 compared to ExtendScript Toolkit 170 elements customizing appearance 175 changing appearance with layout object 109...
  • Page 194 Adobe GoLive CS2 SDK SDK Programmer’s Guide Index getting files from a folder 130 images manipulating files on disk 127 drawing into custom element boxes 84 prompting the user to choose 126 updating dynamically 91 remote file access 133 using for palette icons 80...
  • Page 195 Adobe GoLive CS2 SDK SDK Programmer’s Guide Index reloading function definitions 171 sharing data 34 Key Map sample 76 multicolumn list boxes 70 keyboard shortcuts in menus 45 naming conventions 28 language customization 149 navigating a node tree 104 language translation tables 149...
  • Page 196 Adobe GoLive CS2 SDK SDK Programmer’s Guide Index prompting for a file 126 split panels 64 property values style sheets 99 accessing 27 styles case sensitivity 28 applying to cells 120 undefined 28 applying to tables 118 applying to text 115...
  • Page 197 Adobe GoLive CS2 SDK SDK Programmer’s Guide Index timeline-triggered actions 156 timeouts variable scope 31 for calls to external code 186 version control systems 145 for JavaScript execution 37 views 63 timers 37 virtual elements 95 toggled menu items 46...

Table of Contents