Home Reference Source Test Repository
public class | source

Dropdown

Class to create custom dropdown menus, backed by HTML <select> objects.

Constructor Summary

Public Constructor
public

constructor(selectElement: Element)

Constructs a Dropdown object.

Member Summary

Public Members
public
public

display: *

public
public

menu: *

public
public
public
public get

Returns the value of the selected option.

Method Summary

Public Methods
public

Creates a dropdown menu by appending HTML as a sibling of the select element.

public

Display the selected dropdown option by copying the content to the dropdown display area.

public

Returns an HTML string containing all the options for the dropdown menu.

public

Hide the dropdown menu.

public

Initialize all event listeners for the dropdown menu.

public

selectOption(optionElement: Element)

Selects an option in the dropdown menu and updates the display.

public

Show the dropdown menu.

public

Toggle the display of the dropdown menu.

public

Update all the displayed dropdown options using their respective init() functions in the "optionContent" field.

public

Update the status of the options and display the selected option.

Public Constructors

public constructor(selectElement: Element) source

Constructs a Dropdown object.

Params:

NameTypeAttributeDescription
selectElement Element

Select DOM element.

Public Members

public container: * source

public display: * source

public isDisplayingMenu: boolean source

public menu: * source

public optionlist: * source

public selectElement: * source

public selectedOption: * source

public get value: string: * source

Returns the value of the selected option.

Return:

string

Value of the selected option.

Public Methods

public createDropdown() source

Creates a dropdown menu by appending HTML as a sibling of the select element.

public displaySelectedOption() source

Display the selected dropdown option by copying the content to the dropdown display area. If the content includes a canvas, the content of the canvas will be copied as well.

public getOptionsHtml(): string source

Returns an HTML string containing all the options for the dropdown menu.

Return:

string

HTML string containing all the options for the dropdown menu.

public hideMenu() source

Hide the dropdown menu.

public initListeners() source

Initialize all event listeners for the dropdown menu.

public selectOption(optionElement: Element) source

Selects an option in the dropdown menu and updates the display.

Params:

NameTypeAttributeDescription
optionElement Element

The option that was selected.

public showMenu() source

Show the dropdown menu.

public toggleMenu() source

Toggle the display of the dropdown menu.

public updateOptionContent() source

Update all the displayed dropdown options using their respective init() functions in the "optionContent" field.

public updateOptions() source

Update the status of the options and display the selected option. This is called when the options in the <select> element change.