Adobe 65007312 Programming Guide - Page 143

Specifying in-place edit, The JavaScript file

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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

C
HAPTER
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()
:
Specifying in-place edit
Your JavaScript code can call
inPlaceEdit()
directly, using
callCallback()
. You must provide these
arguments:
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.
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.
target
string
The dot-path identifier of a metadata property defined in your model,
such as "metadata.siteTitle.value"
x, y
width, height
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.
fontFamily
string
The font family to use for the edit.
fontSize
number
The font point size.