Class: Header

Header


A class which contains header APIs.

You must NOT instantiate this yourself. Access the header instance in setHeaderItems as follows:
Example
WebViewer(...)
  .then(function(instance) {
    instance.setHeaderItems(function(header) {
      // instance of Header is passed to the callback
    });
  });

Methods


delete( [id])

Delete a button.
Parameters:
Name Type Argument Description
id number | string <optional>
You can either pass an index or `data-element` of the button to delete. If you already selected a button from get, passing null would delete the selected button.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

get(dataElement)

Select a button from header to edit.
Parameters:
Name Type Description
dataElement string data-element of the button.
Returns:
Header object for chaining. You can call insertBefore, insertAfter and delete to perform an operation on the button.
Type
Header

getHeader(headerGroup)

Select a header group to edit.
Parameters:
Name Type Description
headerGroup string Name of the header group. Possible options are 'default', 'small-mobile-more-buttons', 'toolbarGroup-View', 'toolbarGroup-Annotate', 'toolbarGroup-Shapes', 'toolbarGroup-Insert', 'toolbarGroup-Measure', and 'toolbarGroup-Edit'
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

getItems()

Get all list of header items from a group selected from getHeader. By default, it returns the items from 'default' group.
Returns:
List of header item objects. You can edit it using normal array operations and update the whole header by passing it to update.
Type
Array.<object>

insertAfter(obj)

Insert a button after the selected button from get.
Parameters:
Name Type Description
obj object A header object. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

insertBefore(obj)

Insert a button before the selected button from get.
Parameters:
Name Type Description
obj object A header object. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

pop()

Removes the last button in the header.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

push(obj)

Adds a button (or buttons) to the end of the header.
Parameters:
Name Type Description
obj object | Array.<object> Either one or array of header objects. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

shift()

Removes the first button in the header.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

unshift(obj)

Adds a button (or buttons) to the beginning of the header.
Parameters:
Name Type Description
obj object | Array.<object> Either one or array of header objects. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header

update(headerObjects)

Updates the header with new list of header items.
Parameters:
Name Type Description
headerObjects Array.<object> List of header objects to replace the exising header. You can use getItems to refer to existing header objects.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
Type
Header