Adobe 65007312 Programming Guide - Page 143
Specifying in-place edit, The JavaScript file
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 143 highlights
CHAPTER 6: Writing a Web-engine Plug-in Web HTML Live Update 143 To call from JavaScript into Lightroom, invoke the callCallback() function defined in live_update.js, using this syntax: callCallback( "callback_name", param1, param2, ... ); For example, to call the in-place-edit callback defined in the sample implementation, the JavaScript makes this call: callCallback( 'inPlaceEdit', target, bounds.x, bounds.y, bounds.width, bounds.height, font.fontFamily, font.fontSize, imageID ) Lightroom provides these callback functions that can be invoked from JavaScript using callCallback(): showInPhotoBin = function( id ) Reveals a photo in the filmstrip whose id_global value matches the given id value. setActiveImageSize = function( size ) Tells Lightroom which of the sizes is currently being displayed on screen. Use the same string labels that you provided in the photoSizes section of the galleryInfo.lrweb file. inPlaceEdit = function( target, x, y, width, height, fontFamily, fontSize ) Edits a text field at given coordinates on the screen. See "Specifying in-place edit" on page 143. updateModel = function( key, value ) Alters the data model for the given dot-separated key path. fetchURL = function( url, callbackName ) Downloads the contents of a given URL and returns it as a string. This is an asynchronous operation.When the operation is complete, the result string is passed to the callback. Implement the referenced callback function in the document object. Specifying in-place edit Your JavaScript code can call inPlaceEdit() directly, using callCallback(). You must provide these arguments: target x, y width, height fontFamily fontSize string The dot-path identifier of a metadata property defined in your model, such as "metadata.siteTitle.value" number The bounds of the element on the web page, in pixels. These coordinates are used to position the edit text window that is temporarily superimposed on the web page. string The font family to use for the edit. number The font point size. The JavaScript file live_update.js also provides an easier way to implement in-place edit, by using the clickTarget() function. This function gets the bounds and font information for a particular node in the page DOM, and uses it to call the inPlaceEdit() function.