Skip to main content

Class: TypedVariableModal

Defined in: TypedVariableModal.js:19

Class for displaying a modal used for creating typed variables.

Extends​

  • unknown

Properties index​

PropertyDescription
firstTypeInput_The first type input.
shouldCloseOnOverlayClickIf true close the modal when the user clicks outside the modal. Otherwise, only close when user hits the 'X' button or escape.
types_An array holding arrays with the name of the type and the display name for the type. Ex: [['Penguin', 'PENGUIN'], ['Giraffe', 'GIRAFFE']].
variableNameInput_The input div holding the name of the variable.
variableTypesDiv_The div holding the list of variable types.

Methods index​

MethodDescription
createCancelBtn_Create button in charge of cancelling.
createConfirmBtn_Create button in charge of creating the variable.
createVariableTypeContainer_Creates an unordered list containing all the types.
createVarNameContainer_Create the div that holds the text input and label for the variable name input.
disposeDispose of the typed variable modal.
getSelectedType_Get the selected type.
initCreate a typed variable modal and display it on the given button name.
onConfirm_Get the function to be called when the user tries to create a variable.
renderContent_Render content for the modal content div.
renderFooter_Render content for the modal footer.
resetModalInputs_Check the first type in the list.
setLocaleSet the messages for the typed variable modal. Used to change the location.
widgetDispose_Disposes of any events or dom-references belonging to the editor and resets the inputs.

Constructors​

Constructor​

new TypedVariableModal(
workspace,
btnCallbackName,
types,
optMessages
): TypedVariableModal;

Defined in: TypedVariableModal.js:32

Constructor for creating a typed variable modal.

Parameters​

ParameterTypeDescription
workspaceWorkspaceSvgThe workspace that the modal will be registered on.
btnCallbackNamestringThe name used to register the button callback.
typesstring[][]An array holding arrays with the display name as the first value and the type as the second. Ex: [['Penguin', 'PENGUIN'], ['Giraffe', 'GIRAFFE']].
optMessagesTypedVarModalMessagesThe messages for a typed variable modal.

Returns​

TypedVariableModal

Overrides​

Modal.constructor

Properties​

firstTypeInput_​

protected firstTypeInput_: HTMLInputElement;

Defined in: TypedVariableModal.js:64

The first type input.


shouldCloseOnOverlayClick​

shouldCloseOnOverlayClick: boolean;

Defined in: TypedVariableModal.js:101

If true close the modal when the user clicks outside the modal. Otherwise, only close when user hits the 'X' button or escape.


types_​

protected types_: string[][];

Defined in: TypedVariableModal.js:79

An array holding arrays with the name of the type and the display name for the type. Ex: [['Penguin', 'PENGUIN'], ['Giraffe', 'GIRAFFE']].


variableNameInput_​

protected variableNameInput_: HTMLInputElement;

Defined in: TypedVariableModal.js:50

The input div holding the name of the variable.


variableTypesDiv_​

protected variableTypesDiv_: HTMLElement;

Defined in: TypedVariableModal.js:57

The div holding the list of variable types.

Methods​

createCancelBtn_()​

protected createCancelBtn_(): HTMLButtonElement;

Defined in: TypedVariableModal.js:288

Create button in charge of cancelling.

Returns​

HTMLButtonElement

The button in charge of cancelling.


createConfirmBtn_()​

protected createConfirmBtn_(): HTMLButtonElement;

Defined in: TypedVariableModal.js:275

Create button in charge of creating the variable.

Returns​

HTMLButtonElement

The button in charge of creating a variable.


createVariableTypeContainer_()​

protected createVariableTypeContainer_(types): HTMLElement;

Defined in: TypedVariableModal.js:314

Creates an unordered list containing all the types.

Parameters​

ParameterTypeDescription
typesstring[][]An array holding arrays with the display name as the first value and the type as the second. Ex: [['Penguin', 'PENGUIN'], ['Giraffe', 'GIRAFFE']].

Returns​

HTMLElement

The list of types.


createVarNameContainer_()​

protected createVarNameContainer_(): HTMLDivElement;

Defined in: TypedVariableModal.js:349

Create the div that holds the text input and label for the variable name input.

Returns​

HTMLDivElement

The div holding the text input and label for text input.


dispose()​

dispose(): void;

Defined in: TypedVariableModal.js:142

Dispose of the typed variable modal.

Returns​

void


getSelectedType_()​

protected getSelectedType_(): string | null;

Defined in: TypedVariableModal.js:152

Get the selected type.

Returns​

string | null

The selected type.


init()​

init(): void;

Defined in: TypedVariableModal.js:119

Create a typed variable modal and display it on the given button name.

Returns​

void


onConfirm_()​

protected onConfirm_(): void;

Defined in: TypedVariableModal.js:170

Get the function to be called when the user tries to create a variable.

Returns​

void


renderContent_()​

renderContent_(contentContainer): void;

Defined in: TypedVariableModal.js:243

Render content for the modal content div.

Parameters​

ParameterTypeDescription
contentContainerHTMLDivElementThe modal's content div.

Returns​

void


renderFooter_()​

renderFooter_(footerContainer): void;

Defined in: TypedVariableModal.js:265

Render content for the modal footer.

Parameters​

ParameterTypeDescription
footerContainerHTMLElementThe modal's footer div.

Returns​

void


resetModalInputs_()​

protected resetModalInputs_(): void;

Defined in: TypedVariableModal.js:300

Check the first type in the list.

Returns​

void


setLocale()​

setLocale(messages): void;

Defined in: TypedVariableModal.js:132

Set the messages for the typed variable modal. Used to change the location.

Parameters​

ParameterTypeDescription
messagesTypedVarModalMessagesThe messages needed to create a typed modal.

Returns​

void


widgetDispose_()​

widgetDispose_(): void;

Defined in: TypedVariableModal.js:161

Disposes of any events or dom-references belonging to the editor and resets the inputs.

Returns​

void