Create drop-down list for Web Document Viewer UI
In This Topic
Here is JavaScript code that shows how to create a drop-down list and add created list to the "Tools" menu in VintaSoft web document viewer:
/**
Initializes main menu of Vintasoft web document viewer.
@param {object} docViewerSettings Settings of Vintasoft web document viewer.
*/
function __initMenu(docViewerSettings) {
// get items of document viewer
var items = docViewerSettings.get_Items();
// get the main menu of document viewer
var mainMenu = items.getItemByRegisteredId("mainMenu");
// if main menu is found
if (mainMenu != null) {
// get items of main menu
var mainMenuItems = mainMenu.get_Items();
// get "Tools" menu in web document viewer
var toolsToolbarPanel = mainMenuItems.getItemByRegisteredId("toolsMenuPanel");
// get items of "Tools" menu
var toolsToolbarPanelItems = toolsToolbarPanel.get_Items();
// items for drop-down list
var dropDownItems = ["None", "Accepted", "Completed", "Rejected", "Cancelled"];
// an array that contains option-elements for drop-down list
var selectOptions = [];
// for each item in drop-down list
for (var i = 0; i < dropDownItems.length; i++) {
// create option-element for item
selectOptions.push({
name: dropDownItems[i],
value: dropDownItems[i],
localizationId: dropDownItems[i]
});
}
// create a drop-down list
var dropDownList = new Vintasoft.Imaging.UI.UIElements.WebUiLabelWithDropDownListJS({
css: { width: "100px" },
options: selectOptions,
selectedValue: selectOptions[0]
});
// add drop-down list to the "Tools" menu in web document viewer
toolsToolbarPanelItems.addItem(dropDownList);
}
}
Here is screenshot of VintaSoft web document viewer with drop-down list, which was created using JS-code above: