Adobe 65007312 Programming Guide - Page 142
Example live-update implementation, Defining messages from a previewed to Lightroom
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 142 highlights
CHAPTER 6: Writing a Web-engine Plug-in Web HTML Live Update 142 This function must locate the image using document.getElementById(), and set its dimensions using appropriate DOM methods. The function has this prototype: document.liveUpdateImageSize = function( imageID, width, height ) { // your code here return "invalidateAllContent"; } imageID width height The unique identifier of the image. The new image width in pixels. The new image height in pixels. If unable to perform the live update, return "failed". In this case, Lightroom reloads the browser as often as it can while the mouse is dragged. Example live-update implementation The Lightroom SDK includes the source code for the default HTML web engine, which includes an example implementation of document.liveUpdate() in the file live_update.js. To include this file in your project, you must construct your data model to match the names used in the JavaScript. X For any gallery text fields, you must place an id attribute on the immediately enclosing element. X The id value must match the dot-separated path to the corresponding model value defined in the galleryInfo.lrweb file. For example, in the default HTML gallery, the site title is in an h1 element. In the template source file it looks like this: $model.metadata.siteTitle.value Notice that the id is the same as the path in the model definition in the galleryInfo.lrweb file: ["metadata.siteTitle.value"] = "Site Title", NOTE: This example implementation issues a reload for compound cssID values, such as "#myId.myClass". Create unique classes for such cases to avoid the reload. Defining messages from a previewed page to Lightroom Lightroom provides a callback mechanism whereby JavaScript code running in the previewed page can communicate with Lightroom. The implementation differs slightly in Mac OS and in Windows, but the example live_update.js implements a wrapper function which hides this difference. This discussion assumes that you are including live_update.js in your web-engine folder.