utils

Description:
  • The utils module provides a variety of helper functions to parse and convert variables, get coordinates, and validate parameters.

Source:

The utils module provides a variety of helper functions to parse and convert variables, get coordinates, and validate parameters.

Methods

(inner) getElementCoordinates(element) → {Object}

Description:
  • Gets the width, height, top, and left coordinate in the client space for any DOM element. Used to retrieve the dimensions of the tooltip target.

Source:
Parameters:
Name Type Description
element DOM.element

The DOM element whose tooltip is being queried.

Returns:

The width, height, top, and left coordinate in the client space.

Type
Object

(inner) overlap(coords) → {Object}

Description:
  • Computes the percent of a div element that is within the bounds of the viewport. Used to support optimum-orientaton.

Source:
Since:
  • v2.2.0
Parameters:
Name Type Description
coords Object

The absolute coordinates {x0, x1, y0, y1} of the div element of interest.

Returns:

An object containing the side, overlap, and the spacing around each side.

Type
Object

(inner) hexToRgb(hex) → {string}

Description:
  • Converts a CSS string formatted as hex to rgb format.

Source:
Parameters:
Name Type Description
hex string

The hex representation of the CSS color

Returns:

The color formatted as an rgb string.

Type
string

(inner) createPseudoDiv(template) → {HTML.div}

Description:
  • Creates a hidden div element to facillitate parsing of colors and sizes. If the template argument is passed clones the div properties from it.

Source:
Since:
  • v2.2.0
Parameters:
Name Type Description
template HTML.div

An existing div element.

Returns:

A hidden div element.

Type
HTML.div

(inner) parseColor(color) → {string}

Description:
  • Parses any valid CSS color

Source:
Parameters:
Name Type Description
color string

Any valid CSS color.

Returns:

The CSS color formatted as an rgb string. If opacity values (e.g., rgba) are passed, the opacity is stripped out and simple rgb is returned.

Type
string

(inner) parseSize(size, dimension, template) → {number}

Description:
  • Parses any valid CSS size.

Source:
Parameters:
Name Type Description
size number | string

Any valid CSS size (e.g. 12px, 3em).

dimension string

The dimension ['width' | 'height'] to return. Default: 'width'.

template HTML.div

A div element containing the style options of a tooltip. If the size to be computed, this argument must be passed.

Returns:

The size in pixels (without the 'px' suffix).

Type
number

(inner) checkSize(size) → {boolean}

Description:
  • Validates that the size is a valid CSS size.

Source:
Since:
  • v2.2.0
Parameters:
Name Type Description
size string

Any valid CSS size (e.g. 12px, 3em).

Returns:

True if the size argument is a valid size, false otherwise - logs an error to the console.

Type
boolean

(inner) checkBoolean(argument, argumentName) → {boolean}

Description:
  • Validates whether an input is boolean [true | false].

Source:
Since:
  • v2.1.0
Parameters:
Name Type Description
argument any | boolean

The argument to be checked.

argumentName string

A string representation of the calling function.

Returns:

True if the argument is boolean, false otherwise - logs an error to the console.

Type
boolean

(inner) checkFontFamily(argument) → {boolean}

Description:
  • Validates whether a font family is available on the browser. Note not all browsers support the FontFaceSet interface (esp. all versions of Internet Explorer - if you are still using IE, I'm coming to your house and setting your computer on fire).

Source:
Since:
  • v2.1.0
Parameters:
Name Type Description
argument string

The font family being checked.

Returns:

True if the font is available or the FontFaceSet interface is unsupported, false otherwise - logs an error to the console

Type
boolean

(inner) checkCSS(rule, style) → {boolean}

Description:
  • Validates whether a CSS value is valid. It does this by setting the value in a temporary div element and the checking to see if the style has indeed changed.

Source:
Since:
  • v2.1.0
Parameters:
Name Type Description
rule string

The CSS rule (e.g., padding, border-radius, etc.) being checked.

style string

The style to validate.

Returns:

True if the CSS is valid, false otherwise - logs an error to the console

Type
boolean

Events

windowResized

Description:
Source: