Customize Popups and the Popup API in WebViewer Using JavaScript
The popups in WebViewer UI are small floating menus.
In WebViewer UI, there are 4 types of popups:
context menu popup; appears on right click of a blank space

text popup; appears on highlight of a text when using select tool

annotation popup; appears on selection of annotation(s)

content overlay popup; appears on hover of annotation(s)

There are a number of ways you may want to customize Popups. To name a few:
The WebViewer UI provides API's to easily handle each of these cases and more.
Get items
The unique identifier of the items in the popup can be retrieved using the getItems API. It returns an array of objects where each object contains a key that denotes the dataElement.
Adding items
Adding items can be done using the add API. The type of items to add can be found in the list of items for Modular UI.
Add new items at beginning of the popup
To add new items at beginning of the popup, do not provide a second parameter to the add function.
Add new items at a specific location in the popup
There are 2 ways to do this.
Option one:
If you know the specific element you want it to be after then you can provide a valid dataElement string as a second parameter. This will insert the new item(s) after the specified data element.
Option two:
If you know the index where you want to add it (for example as the last button) then you can get the list of data elements in the popup using the getItems API. Then retrieve the data element from the item at that index.
Modifying items
Existing items can be modified using updateElements. The items in the popup can be replaced using update.
Update existing elements' properties
Replace existing elements
Update ordering of elements in the popup
This can be done by:
Get the list of data elements in the popup using the getItems API
Modify ordering of the elements in the list retrieved from step 1.
call update
Deleting items
Items in the popup can be deleted using the using disableElements.
Adds a custom overlay to annotation on hover
Customizing Popups with the Modular UI
When using the Modular UI, you can continue using existing Popup APIs. As of 11.8, you can also customize Popups using configuration files, making it easy to audit your current customizations at a glance or maintain different variants for different use cases.
To recap, there are three Popups you can customize using these APIs:
AnnotationPopup: Appears when you select an annotation.
ContextMenuPopup: Appears when you right-click anywhere on the viewer container.
TextPopup: Appears when you select text.
For example, you may want to add a ToolButton to the ContextMenuPopup, so users can quickly access commonly used tools:
Notice that we used a ToolButton as defined in the items documentation. Popups in the Modular UI support the following item types:
Customizing via the configuration file
Starting in 11.8, when you call exportModularComponents, you will see a new key in the JSON for the three customizable Popups:
Each Popup will be a key in the JSON, with a list of the buttons it contains. The dataElements point to buttons the UI ships by default, such as the annotationStyleEditButton which toggles the Style Panel.
As with any custom component in the Modular UI, if you pass custom handlers or render functions, make sure those functions are added to the FunctionMap when importing your configuration. See the FunctionMap guide for more in-depth examples.
Last updated
Was this helpful?