Methods
Initialization Example:
// create the FSI ImageGrid Element and set parameters
const instance = document.createElement("fsi-imagegrid")
instance.setAttribute('id', 'myGrid')
instance.setAttribute('dir', 'images/samples/grid/colour')
instance.setAttribute('cellWidth', '120')
instance.setAttribute('cellHeight', '120')
instance.setAttribute('autoCrop', 'cc')
instance.setAttribute('debug', true)
instance.style.width = '800px'
instance.style.height = '400px'
document.body.appendChild(instance)
// Example: add listener onCellClick
const success = instance.addListener('onCellClick', (event, cell) => {
console.log('You clicked on: ', event, cell)
// do stuff here, Example:
// adding method getImageDownloadURL using the nIndex parameter of the cell object passed by onCellClick
const url = instance.getImageDownloadURL(cell.nIndex, 300, 'jpeg', {
quality: 80
})
console.log('Your URL is: ', url)
})
addListener
const success = addListener(listenerName, fn, iScope)
Calls a specific listener. Listeners which are added via addListener(), remain valid when changeConfig() is called.
const success = instance.addListener('onReplaceTemplateValue',
(name, value) => {
// code
})
Example
Consult Callbacks for an overview of all available listeners.
assignFSIViewer
const success = assignFSIViewer(viewerInstance)
Assigns a certain FSI Viewer JS instance to FSI ImageGrid for building FSI Showcase JS.
instance.assignViewer('viewerID')
Example
changeDir
const success = changeDir(dir)
Changes directory used for the grid.
const success = instance.changeDir('images/samples/new-dir')
Example
downloadImage
downloadImage(spriteIndex, maxDim, renderer, [queryParam])
Downloads image with an auto-generated Responsive Imaging URL.
instance.downloadImage(2, 300, 'jpeg', {quality: 80})
Example
downloadSourceImage
downloadSourceImage(spriteIndex)
Downloads the source image with original dimensions directly and opens a Save dialog.
instance.downloadSourceImage(2)
Example
dumpListeners
dumpListeners()
Lists all listeners in the console and how often they were called.
instance.dumpListeners()
Example
getBuild
const version = getBuild()
Returns a string containing the FSI Viewer software build number.
const version = instance.getBuild()
Example
getConfigValue
const value = getConfigValue(name)
Returns the value of any configuration parameter addressed with `name`.
const value = instance.getConfigValue('dir')
Example
getImageCount
const images = getImageCount()
Returns the amount of images used in FSI ThumbBar.
const index = instance.getImageCount()
Example
getImageDownloadURL
getImageDownloadURL(spriteIndex, maxDim, renderer, [queryParam])
Returns an auto-generated Responsive Imaging URL.
instance.getImageDownloadURL(2, 300, 'jpeg', {quality: 80})
// return example:
// 'https://yourdomain.com/fsi/server?quality=80&renderer=jpeg&save=1&width=300&type=image&source=images/samples/image.jpg'
Example
getSourceImageDownloadURL
getSourceImageDownloadURL(spriteIndex)
Returns the direct download URL of the source image. Accessing it opens a save dialog.
instance.getSourceImageDownloadURL(2)
// return example:
// 'https://yourdomain.com/fsi/service/file/images/samples/image.jpg'
Example
getInitDone
const done = getInitDone()
Returns if the initialization process is done.
const done = instance.getInitDone()
Example
getInstanceID
const getID = getInstanceID()
Returns the number of the viewer object.
const getID = instance.getInstanceID()
Example
getInstanceName
const name = getInstanceName()
Returns the type of the viewer (e.g. FSI ImageGrid or FSI Viewer) and the id attribute of the viewer object.
const name = instance.getInstanceName()
Example
getParameters
const param = getParameters()
Returns an object containing all parameters set via javascript or custom tag attributes.
const param = instance.getParameters()
// return example:
/*
{
autocrop: "cc"
cellheight: "325"
cellwidth: "300"
debug: "true"
dir: "/images/samples/grid/"
id: "fsi-grid-fit"
imagelistlimit: "0,16"
oncellclick: "openPopUp"
scroll: "false"
style: "text-align:center;width:100%;height:400px;"
usequickzoom: "false"
usetouchzoom: "true"
}
*/
Example
getScrollPos
const pos = getScrollPos()
Returns the current scroll position.
const pos = instance.getScrollPos()
Example
getVersion
const version = getVersion()
Returns a string containing the FSI ImageGrid software version number.
const version = instance.getVersion()
Example
getVisibleRange
const range = getVisibleRange()
Returns the currently visible image range.
const version = instance.getVisibleRange()
// return example:
// {"start": 0, "end": 15}
Example
init
const success = init(id, options, debug)
Initialises the chosen viewer element.
This method is only needed if FSI ImageGrid has not been started automatically (default).
const success = instance.init('fsi-123', {
dir: 'images/samples/grid',
debug: true,
cellWidth: '90',
cellHeight: '61',
preloadCount: '120',
autoCrop: 'cc'
}, true)
Example
printAPI
printAPI()
Shows all API methods, listeners and button IDs in the console in alphabetical order.
instance.printAPI()
Example
removeListener
const success = removeListener(listenerName, fn)
Removes a specific listener.
const success = instance.removeListener('onCellMouseDown', yourFunction)
Example
scrollToRow
const success = scrollToRow(row, fn)
Scrolls to a certain row.
const success = instance.scrollToRow(2, (functionParam) => {
// code
})
Example
scrollToThumbIndex
const success = scrollToRow(index, fn)
Scrolls to a certain row.
const success = instance.scrollToThumbIndex(5, (functionParam) => {
// code
})
Example
setScrollPos
const position = setScrollPos(position, animFrames)
Sets the scroll position based on the given specifications.
instance.setScrollPos(3,12)
Example
testAPIListenersStart
testAPIListenersStart()
Starts the API test and shows all called listeners and the parameters which they return.
instance.testAPIListenersStart()
Example
testAPIListenersStop
testAPIListenersStop()
Stops the API test.
instance.testAPIListenersStop()
Example
traceConfigValue
const show = traceConfigValue(strName)
Traces a config value and enables you to see where (by parameter/attribute, in config files, the _default.xml, etc) a specific value is set.
const show = instance.traceConfigValue('useTouchZoom')
// return example:
// Tracing parameter "useTouchZoom"
// By Parameter/Attribute:
// true
// RESULT:
// useTouchZoom = "true"
Example