Home Reference Source
public class | source

Utilities

Utility Service

Constructor Summary

Public Constructor
public

Creates an instance of the Utility service

Member Summary

Public Members
public
public

Method Summary

Public Methods
public

addStringAt(source: string, string: string, position: number, moveCaret: boolean): *

Adds a string to the input at a given position

public

camelCase(string: string): *

Transforms an arbitrary string to camelCase

public

countInArray(array: Array, value: string): *

Counts the number of duplicates in a given array

public

Adds default classes to a given button

public

getButtonDisplayName(button: string, display: object, mergeDisplay: boolean): *

Returns the display (label) name for a given button

public

getDefaultDiplay(): {"{bksp}": string, "{backspace}": string, "{enter}": string, "{shift}": string, "{shiftleft}": string, "{shiftright}": string, "{alt}": string, "{s}": string, "{tab}": string, "{lock}": string, "{capslock}": string, "{accept}": string, "{space}": string, "{//}": string, "{esc}": string, "{escape}": string, "{f1}": string, "{f2}": string, "{f3}": string, "{f4}": string, "{f5}": string, "{f6}": string, "{f7}": string, "{f8}": string, "{f9}": string, "{f10}": string, "{f11}": string, "{f12}": string, "{numpaddivide}": string, "{numlock}": string, "{arrowup}": string, "{arrowleft}": string, "{arrowdown}": string, "{arrowright}": string, "{prtscr}": string, "{scrolllock}": string, "{pause}": string, "{insert}": string, "{home}": string, "{pageup}": string, "{delete}": string, "{end}": string, "{pagedown}": string, "{numpadmultiply}": string, "{numpadsubtract}": string, "{numpadadd}": string, "{numpadenter}": string, "{period}": string, "{numpaddecimal}": string, "{numpad0}": string, "{numpad1}": string, "{numpad2}": string, "{numpad3}": string, "{numpad4}": string, "{numpad5}": string, "{numpad6}": string, "{numpad7}": string, "{numpad8}": string, "{numpad9}": string}

Default button display labels

public

getUpdatedInput(button: string, input: string, options: object, caretPos: number, moveCaret: boolean): *

Returns the updated input resulting from clicking a given button

public

handleMaxLength(inputObj: object, options: object, updatedInput: string): boolean

Determines whether the maxLength has been reached.

public

Gets the current value of maxLengthReached

public

removeAt(source: string, position: number, moveCaret: boolean): *

Removes an amount of characters at a given position

public

updateCaretPos(length: number, minus: boolean)

Moves the cursor position by a given amount

public

updateCaretPosAction(instance: object, length: number, minus: boolean)

Action method of updateCaretPos

Public Constructors

public constructor() source

Creates an instance of the Utility service

Public Members

public maxLengthReached: boolean source

public simpleKeyboardInstance: object source

Public Methods

public addStringAt(source: string, string: string, position: number, moveCaret: boolean): * source

Adds a string to the input at a given position

Params:

NameTypeAttributeDescription
source string

The source input

string string

The string to add

position number

The (cursor) position where the string should be added

moveCaret boolean

Whether to update simple-keyboard's cursor

Return:

*

public camelCase(string: string): * source

Transforms an arbitrary string to camelCase

Params:

NameTypeAttributeDescription
string string

The string to transform.

Return:

*

public countInArray(array: Array, value: string): * source

Counts the number of duplicates in a given array

Params:

NameTypeAttributeDescription
array Array

The haystack to search in

value string

The needle to search for

Return:

*

public getButtonClass(button: string): string source

Adds default classes to a given button

Params:

NameTypeAttributeDescription
button string

The button's layout name

Return:

string

The classes to be added to the button

public getButtonDisplayName(button: string, display: object, mergeDisplay: boolean): * source

Returns the display (label) name for a given button

Params:

NameTypeAttributeDescription
button string

The button's layout name

display object

The provided display option

mergeDisplay boolean

Whether the provided param value should be merged with the default one.

Return:

*

public getDefaultDiplay(): {"{bksp}": string, "{backspace}": string, "{enter}": string, "{shift}": string, "{shiftleft}": string, "{shiftright}": string, "{alt}": string, "{s}": string, "{tab}": string, "{lock}": string, "{capslock}": string, "{accept}": string, "{space}": string, "{//}": string, "{esc}": string, "{escape}": string, "{f1}": string, "{f2}": string, "{f3}": string, "{f4}": string, "{f5}": string, "{f6}": string, "{f7}": string, "{f8}": string, "{f9}": string, "{f10}": string, "{f11}": string, "{f12}": string, "{numpaddivide}": string, "{numlock}": string, "{arrowup}": string, "{arrowleft}": string, "{arrowdown}": string, "{arrowright}": string, "{prtscr}": string, "{scrolllock}": string, "{pause}": string, "{insert}": string, "{home}": string, "{pageup}": string, "{delete}": string, "{end}": string, "{pagedown}": string, "{numpadmultiply}": string, "{numpadsubtract}": string, "{numpadadd}": string, "{numpadenter}": string, "{period}": string, "{numpaddecimal}": string, "{numpad0}": string, "{numpad1}": string, "{numpad2}": string, "{numpad3}": string, "{numpad4}": string, "{numpad5}": string, "{numpad6}": string, "{numpad7}": string, "{numpad8}": string, "{numpad9}": string} source

Default button display labels

Return:

{"{bksp}": string, "{backspace}": string, "{enter}": string, "{shift}": string, "{shiftleft}": string, "{shiftright}": string, "{alt}": string, "{s}": string, "{tab}": string, "{lock}": string, "{capslock}": string, "{accept}": string, "{space}": string, "{//}": string, "{esc}": string, "{escape}": string, "{f1}": string, "{f2}": string, "{f3}": string, "{f4}": string, "{f5}": string, "{f6}": string, "{f7}": string, "{f8}": string, "{f9}": string, "{f10}": string, "{f11}": string, "{f12}": string, "{numpaddivide}": string, "{numlock}": string, "{arrowup}": string, "{arrowleft}": string, "{arrowdown}": string, "{arrowright}": string, "{prtscr}": string, "{scrolllock}": string, "{pause}": string, "{insert}": string, "{home}": string, "{pageup}": string, "{delete}": string, "{end}": string, "{pagedown}": string, "{numpadmultiply}": string, "{numpadsubtract}": string, "{numpadadd}": string, "{numpadenter}": string, "{period}": string, "{numpaddecimal}": string, "{numpad0}": string, "{numpad1}": string, "{numpad2}": string, "{numpad3}": string, "{numpad4}": string, "{numpad5}": string, "{numpad6}": string, "{numpad7}": string, "{numpad8}": string, "{numpad9}": string}

public getUpdatedInput(button: string, input: string, options: object, caretPos: number, moveCaret: boolean): * source

Returns the updated input resulting from clicking a given button

Params:

NameTypeAttributeDescription
button string

The button's layout name

input string

The input string

options object

The simple-keyboard options object

caretPos number

The cursor's current position

moveCaret boolean

Whether to update simple-keyboard's cursor

Return:

*

public handleMaxLength(inputObj: object, options: object, updatedInput: string): boolean source

Determines whether the maxLength has been reached. This function is called when the maxLength option it set.

Params:

NameTypeAttributeDescription
inputObj object
options object
updatedInput string

Return:

boolean

public isMaxLengthReached(): * source

Gets the current value of maxLengthReached

Return:

*

public removeAt(source: string, position: number, moveCaret: boolean): * source

Removes an amount of characters at a given position

Params:

NameTypeAttributeDescription
source string

The source input

position number

The (cursor) position from where the characters should be removed

moveCaret boolean

Whether to update simple-keyboard's cursor

Return:

*

public updateCaretPos(length: number, minus: boolean) source

Moves the cursor position by a given amount

Params:

NameTypeAttributeDescription
length number

Represents by how many characters the input should be moved

minus boolean

Whether the cursor should be moved to the left or not.

public updateCaretPosAction(instance: object, length: number, minus: boolean) source

Action method of updateCaretPos

Params:

NameTypeAttributeDescription
instance object

The instance whose position should be updated

length number

Represents by how many characters the input should be moved

minus boolean

Whether the cursor should be moved to the left or not.