Notification(optionsopt)

new Notification(optionsopt)

Create an instance of a notification handler

Build the notification singleton handler that will handle all incoming Notifications

Parameters:
Name Type Attributes Description
options object <optional>

The notification handler global options

Properties
Name Type Attributes Default Description
position string <optional>
top-right

top-left; top-right; bottom-left; bottom-right;

thickBorder string <optional>
top

top; bottom; left; right; none;

duration number <optional>
3000

Notification life cycle duration (in ms) in range N*

transition number <optional>
100

Notification fade animation transition timing (in ms) in range N*

maxActive number <optional>
5

Maximum of simultaneously opened notification in range N*

Since:
  • June 2018
Author:
  • Arthur Beaulieu

Members

private _active :object

Active notifications object : retrieve a notification using its ID (this._active[ID])

private _default :object

Notification handler default values

private _dismissAllLock :boolean

Dismiss all operation in progress flag

private _dom :object

Notification handler container node

private _duration :number

The Notification on screen duration in ms

private _maxActive :number

The maximum amount of active Notification

private _position :string

The handler position in viewport - top-left; top-right; bottom-left; bottom-right;

private _queue :object

Queue notifications when max active has been reached

private _thickBorder :string

The thick border position in the Notification - top; bottom; left; right; none;

private _transition :number

The fade transition time in ms

version :number

The component version

Methods

private, static _attach()

Attach the notification handler to the dom using a fragment

Since:
  • July 2018
Author:
  • Arthur Beaulieu

private, static _buildNotificationType(notification)

Attach proper assets and css

Fills the Notification icon and class according to its inner type

Parameters:
Name Type Description
notification object

The notification to fill

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _buildUI(notification) → {object}

Builds the DOM element that contains and that adapts to all given options

Parameters:
Name Type Description
notification object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

type string

Error, Warning, Info, Success

title string

Notification title

message string

Notification message

iconless boolean

No icon flag

thickBorder string

Notification border side (override handler side value)

closable boolean

Make notification closable flag

sticky boolean

Make notification sticky flag

CBtitle string

Notification callback title

callback function

Notification callback button

Returns:
object -

Enhanced and ready notification object

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _buildUIDom(notification)

Create the Notification DOM tree

Build all the Notification internal structure

Parameters:
Name Type Description
notification object

The notification to create

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _checkCounter(notification)

This method will reset the fadeout/dim timeout or close/dim the notification depending on its requestCount

Parameters:
Name Type Description
notification Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

requestCount number

Notification inner call counter

dom object

Notifiction DOM element

timeoutID number

Notification own setTimeout ID

sticky boolean

Notification sticky behvaior

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _checkNotificationOptionsValidity(options)

Check the Notification options validity

Check a Notification options object against the required parameters.

Parameters:
Name Type Description
options object

The notification options to check validity

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _clearRequestCount(notification)

Method that clear every pending request

Parameters:
Name Type Description
notification object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

dom object

Notifiction DOM element

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _close(notification)

Close and remove the notification from the container

Parameters:
Name Type Description
notification Object | Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

isClosing boolean

Already closing flag

dom object

Notifiction DOM element

renderTo object

DOM object to render the notification in

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _decrementRequestCounter(notification, force)

This method is called each notification cycle end to update its inner counter

Parameters:
Name Type Description
notification Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

sticky boolean

Notification sticky behvaior

isDimmed boolean

Notification dimmed status (only useful if notification.sticky is true)

requestCount number

Notification inner call counter

dom object

Notification DOM element

force boolean

To force the notification.requestCount decrementation

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _dim(notification)

Only useful for sticky notification that dim instead of close at the end of its life cycle

Parameters:
Name Type Description
notification Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

dom object

Notifiction DOM element

sticky boolean

Notification sticky behvaior

isDimmed boolean

Notification dimmed status (only useful if notification.sticky is true)

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _events(notification)

Handle mouse events for the given notification

Parameters:
Name Type Description
notification Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

dom object

Notifiction DOM element

requestCount number

Notification inner call counter

timeoutID number

Notification own setTimeout ID

sticky boolean

Notification sticky behvaior

closable boolean

Make notification closable flag

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _idGenerator(seed, length)

Generate an ID

Hash the seed to generate an ID

Parameters:
Name Type Description
seed string

The seed string to hash

length number

The length of the returned ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _incrementRequestCounter(notification)

This method is called when a notification is requested another time

Parameters:
Name Type Description
notification object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

requestCount number

Notification inner call counter

dom object

Notifiction DOM element

sticky boolean

Notification sticky behvaior

isDimmed boolean

Notification dimmed status (only useful if notification.sticky is true)

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _init(optionsopt)

Create the handler DOM element, set default values, test given options and properly add CSS class to the handler

Parameters:
Name Type Attributes Description
options object <optional>

The notification handler global options

Properties
Name Type Attributes Default Description
position string <optional>
top-right

top-left; top-right; bottom-left; bottom-right;

thickBorder string <optional>
top

top; bottom; left; right; none;

duration number <optional>
3000

Notification life cycle duration (in ms) in range N*

transition number <optional>
100

Notification fade animation transition timing (in ms) in range N*

maxActive number <optional>
5

Maximum of simultaneously opened notification in range N*

Since:
  • July 2018
Author:
  • Arthur Beaulieu

private, static _open(notification)

Open and add the notification to the container

Parameters:
Name Type Description
notification Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

dom object

Notifiction DOM element

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _resetTimeout(notification)

Use this to reset a notification life cycle, and delay its close event

Parameters:
Name Type Description
notification Object | Object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

timeoutID number

Notification own setTimeout ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _setAttributesDefault()

Check the notification singleton options validity

Fallback on default attributes value if the notification singleton options are invalid

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _setOptionsDefault(options)

Set singleton options

Build the notification singleton according to the user options

Parameters:
Name Type Description
options object

The singleton options to set

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _setOptionsFallback(options)

Set Notification fallback options

Check a Notification options object and fill it with default value in case they are empty.

Parameters:
Name Type Description
options object

The notification options to fill with default value if empty

Since:
  • March 2019
Author:
  • Arthur Beaulieu

private, static _start(notification)

Call this method to add the new notification to the DOM container, and launch its life cycle

Parameters:
Name Type Description
notification object

The notification object

Properties
Name Type Description
id number

Notification own ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

private, static _unDim(notification)

Call this method when a notification is not inactive anymore

Parameters:
Name Type Description
notification object

The notification object

Properties
Name Type Description
id number

Notification personnal ID

dom object

Notifiction DOM element

isDimmed boolean

Notification dimmed status (only useful if notification.sticky is true)

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static destroy()

Destroy the singleton and detach it from the DOM

Since:
  • March 2019
Author:
  • Arthur Beaulieu

static dismiss(id)

Dismiss a specific notification via its ID

Parameters:
Name Type Description
id string

The notification ID to dismiss

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static dismissAll()

Clear the notification handler from all its active notifications

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static dismissType(type)

Dismiss all notifications from a given type

Parameters:
Name Type Description
type string

succes; info; warning; error;

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static error(options) → {number}

Build an error notification

Parameters:
Name Type Description
options object

The notification options object (see new() arguments since this is an abstraction of new())

Returns:
number -

The newly created notification ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static info(options) → {number}

Build an info notification

Parameters:
Name Type Description
options object

The notification options object (see new() arguments since this is an abstraction of new())

Returns:
number -

The newly created notification ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static new(options) → {number}

Build a notification according to the given options, then append it to notification container.

Parameters:
Name Type Description
options object

The notification options object

Properties
Name Type Attributes Default Description
type string

Error; Warning; Info; Success;

title string <optional>
options.type

Notification title

message string

Notification message

duration number <optional>
handler

Notification duration (override handler duration value)

iconless boolean <optional>
false

No icon flag

thickBorder string <optional>
handler

Notification border side (override handler side value)

closable boolean <optional>
true

Make notification closable flag

sticky boolean <optional>
false

Make notification sticky flag

renderTo object <optional>
handler

Dom object to render the notification in

CBtitle string <optional>
Callback

Notification callback title

callback function <optional>

Notification callback button

Returns:
number -

The newly created notification ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static success(options) → {number}

Build a success notification

Parameters:
Name Type Description
options object

The notification options object (see new() arguments since this is an abstraction of new())

Returns:
number -

The newly created notification ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu

static warning(options) → {number}

Build a warning notification

Parameters:
Name Type Description
options object

The notification options object (see new() arguments since this is an abstraction of new())

Returns:
number -

The newly created notification ID

Since:
  • June 2018
Author:
  • Arthur Beaulieu