new Notification(optionsopt)
Notification Singleton Class to automatically handle one or several notification of different types at the same time.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The notification handler global options
Properties
|
- Since:
- June 2018
- Source:
Members
(private) _active :object
Active notifications object : retrieve a notification using its ID (this._active[ID])
Type:
- object
- Source:
(private) _default :objecy
Notification handler default values
Type:
- objecy
- Source:
(private) _dismissAllLock :boolean
Dismiss all operation in progress flag
Type:
- boolean
- Source:
(private) _dom :object
Notification handler container node
Type:
- object
- Source:
(private) _duration :number
The Notification on screen duration in ms
Type:
- number
- Source:
(private) _maxActive :number
The maximum amount of active Notification
Type:
- number
- Source:
(private) _position :string
The handler position in viewport - top-left; top-right; bottom-left; bottom-right;
Type:
- string
- Source:
(private) _queue :object
Queue notifications when max active has been reached
Type:
- object
- Source:
(private) _thickBorder :string
The thick border position in the Notification - top; bottom; left; right; none;
Type:
- string
- Source:
(private) _transition :number
The fade transition time in ms
Type:
- number
- Source:
Methods
(private, static) _attach()
Attach the notification handler to the dom using a fragment
- Since:
- July 2018
- Source:
(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
- Source:
(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
|
- Since:
- June 2018
- Source:
Returns:
Enhanced and ready notification object
- Type
- object
(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
- Source:
(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
|
- Since:
- June 2018
- Source:
(private, static) _checkOptionsValidity(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
- Source:
(private, static) _clearRequestCount(notification)
Method that clear every pending request
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
notification |
object | The notification object
Properties
|
- Since:
- June 2018
- Source:
(private, static) _close(notification)
Close and remove the notification from the container
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
notification |
Object | Object | The notification object
Properties
|
- Since:
- June 2018
- Source:
(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
|
||||||||||||||||||
force |
boolean | To force the notification.requestCount decrementation |
- Since:
- June 2018
- Source:
(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
|
- Since:
- June 2018
- Source:
(private, static) _events(notification)
Handle mouse events for the given notification
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
notification |
Object | The notification object
Properties
|
- Since:
- June 2018
- Source:
(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
- Source:
(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
|
- Since:
- June 2018
- Source:
(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
|
- Since:
- July 2018
- Source:
(private, static) _open(notification)
Open and add the notification to the container
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
notification |
Object | The notification object
Properties
|
- Since:
- June 2018
- Source:
(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
|
- Since:
- June 2018
- Source:
(private, static) _setAttributesDefault()
Check the notification singleton options validity
Fallback on default attributes value if the notification singleton options are invalid
- Since:
- March 2019
- Source:
(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
- Source:
(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
- Source:
(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
|
- Since:
- June 2018
- Source:
(private, static) _unDim(notification)
Call this method when a notification is not inactive anymore
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
notification |
object | The notification object
Properties
|
- Since:
- June 2018
- Source:
(static) dismiss(id)
Dismiss a specific notification via its ID
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The notification ID to dismiss |
- Since:
- June 2018
- Source:
(static) dismissAll()
Clear the notification handler from all its active notifications
- Since:
- June 2018
- Source:
(static) dismissType(type)
Dismiss all notifications from a given type
Parameters:
Name | Type | Description |
---|---|---|
type |
string | succes; info; warning; error; |
- Since:
- June 2018
- Source:
(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()) |
- Since:
- June 2018
- Source:
Returns:
The newly created notification ID
- Type
- number
(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()) |
- Since:
- June 2018
- Source:
Returns:
The newly created notification ID
- Type
- number
(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
|
- Since:
- June 2018
- Source:
Returns:
The newly created notification ID
- Type
- number
(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()) |
- Since:
- June 2018
- Source:
Returns:
The newly created notification ID
- Type
- number
(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()) |
- Since:
- June 2018
- Source:
Returns:
The newly created notification ID
- Type
- number