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
|
- Since:
- June 2018
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
-
private, static _buildNotificationType(notification)
Attach proper assets and css
-
Fills the Notification icon and class according to its inner type
Parameters:
Name Type Description notificationobject The notification to fill
- Since:
- March 2019
-
private, static _buildUI(notification) → {object}
-
Builds the DOM element that contains and that adapts to all given options
Parameters:
Name Type Description notificationobject The notification object
Properties
Name Type Description idnumber Notification personnal ID
typestring Error, Warning, Info, Success
titlestring Notification title
messagestring Notification message
iconlessboolean No icon flag
thickBorderstring Notification border side (override handler side value)
closableboolean Make notification closable flag
stickyboolean Make notification sticky flag
CBtitlestring Notification callback title
callbackfunction Notification callback button
Returns:
object -Enhanced and ready notification object
- Since:
- June 2018
-
private, static _buildUIDom(notification)
Create the Notification DOM tree
-
Build all the Notification internal structure
Parameters:
Name Type Description notificationobject The notification to create
- Since:
- March 2019
-
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 notificationObject The notification object
Properties
Name Type Description idnumber Notification personnal ID
requestCountnumber Notification inner call counter
domobject Notifiction DOM element
timeoutIDnumber Notification own setTimeout ID
stickyboolean Notification sticky behvaior
- Since:
- June 2018
-
private, static _checkNotificationOptionsValidity(options)
Check the Notification options validity
-
Check a Notification options object against the required parameters.
Parameters:
Name Type Description optionsobject The notification options to check validity
- Since:
- March 2019
-
private, static _clearRequestCount(notification)
-
Method that clear every pending request
Parameters:
Name Type Description notificationobject The notification object
Properties
Name Type Description idnumber Notification personnal ID
domobject Notifiction DOM element
- Since:
- June 2018
-
private, static _close(notification)
-
Close and remove the notification from the container
Parameters:
Name Type Description notificationObject | Object The notification object
Properties
Name Type Description idnumber Notification personnal ID
isClosingboolean Already closing flag
domobject Notifiction DOM element
renderToobject DOM object to render the notification in
- Since:
- June 2018
-
private, static _decrementRequestCounter(notification, force)
-
This method is called each notification cycle end to update its inner counter
Parameters:
Name Type Description notificationObject The notification object
Properties
Name Type Description idnumber Notification personnal ID
stickyboolean Notification sticky behvaior
isDimmedboolean Notification dimmed status (only useful if notification.sticky is true)
requestCountnumber Notification inner call counter
domobject Notification DOM element
forceboolean To force the notification.requestCount decrementation
- Since:
- June 2018
-
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 notificationObject The notification object
Properties
Name Type Description idnumber Notification personnal ID
domobject Notifiction DOM element
stickyboolean Notification sticky behvaior
isDimmedboolean Notification dimmed status (only useful if notification.sticky is true)
- Since:
- June 2018
-
private, static _events(notification)
-
Handle mouse events for the given notification
Parameters:
Name Type Description notificationObject The notification object
Properties
Name Type Description idnumber Notification personnal ID
domobject Notifiction DOM element
requestCountnumber Notification inner call counter
timeoutIDnumber Notification own setTimeout ID
stickyboolean Notification sticky behvaior
closableboolean Make notification closable flag
- Since:
- June 2018
-
private, static _idGenerator(seed, length)
Generate an ID
-
Hash the seed to generate an ID
Parameters:
Name Type Description seedstring The seed string to hash
lengthnumber The length of the returned ID
- Since:
- June 2018
-
private, static _incrementRequestCounter(notification)
-
This method is called when a notification is requested another time
Parameters:
Name Type Description notificationobject The notification object
Properties
Name Type Description idnumber Notification personnal ID
requestCountnumber Notification inner call counter
domobject Notifiction DOM element
stickyboolean Notification sticky behvaior
isDimmedboolean Notification dimmed status (only useful if notification.sticky is true)
- Since:
- June 2018
-
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 optionsobject <optional>
The notification handler global options
Properties
Name Type Attributes Default Description positionstring <optional>
top-right top-left; top-right; bottom-left; bottom-right;
thickBorderstring <optional>
top top; bottom; left; right; none;
durationnumber <optional>
3000 Notification life cycle duration (in ms) in range N*
transitionnumber <optional>
100 Notification fade animation transition timing (in ms) in range N*
maxActivenumber <optional>
5 Maximum of simultaneously opened notification in range N*
- Since:
- July 2018
-
private, static _open(notification)
-
Open and add the notification to the container
Parameters:
Name Type Description notificationObject The notification object
Properties
Name Type Description idnumber Notification personnal ID
domobject Notifiction DOM element
- Since:
- June 2018
-
private, static _resetTimeout(notification)
-
Use this to reset a notification life cycle, and delay its close event
Parameters:
Name Type Description notificationObject | Object The notification object
Properties
Name Type Description idnumber Notification personnal ID
timeoutIDnumber Notification own setTimeout ID
- Since:
- June 2018
-
private, static _setAttributesDefault()
Check the notification singleton options validity
-
Fallback on default attributes value if the notification singleton options are invalid
- Since:
- March 2019
-
private, static _setOptionsDefault(options)
Set singleton options
-
Build the notification singleton according to the user options
Parameters:
Name Type Description optionsobject The singleton options to set
- Since:
- March 2019
-
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 optionsobject The notification options to fill with default value if empty
- Since:
- March 2019
-
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 notificationobject The notification object
Properties
Name Type Description idnumber Notification own ID
- Since:
- June 2018
-
private, static _unDim(notification)
-
Call this method when a notification is not inactive anymore
Parameters:
Name Type Description notificationobject The notification object
Properties
Name Type Description idnumber Notification personnal ID
domobject Notifiction DOM element
isDimmedboolean Notification dimmed status (only useful if notification.sticky is true)
- Since:
- June 2018
-
static destroy()
-
Destroy the singleton and detach it from the DOM
- Since:
- March 2019
-
static dismiss(id)
-
Dismiss a specific notification via its ID
Parameters:
Name Type Description idstring The notification ID to dismiss
- Since:
- June 2018
-
static dismissAll()
-
Clear the notification handler from all its active notifications
- Since:
- June 2018
-
static dismissType(type)
-
Dismiss all notifications from a given type
Parameters:
Name Type Description typestring succes; info; warning; error;
- Since:
- June 2018
-
static error(options) → {number}
-
Build an error notification
Parameters:
Name Type Description optionsobject The notification options object (see new() arguments since this is an abstraction of new())
Returns:
number -The newly created notification ID
- Since:
- June 2018
-
static info(options) → {number}
-
Build an info notification
Parameters:
Name Type Description optionsobject The notification options object (see new() arguments since this is an abstraction of new())
Returns:
number -The newly created notification ID
- Since:
- June 2018
-
static new(options) → {number}
-
Build a notification according to the given options, then append it to notification container.
Parameters:
Name Type Description optionsobject The notification options object
Properties
Name Type Attributes Default Description typestring Error; Warning; Info; Success;
titlestring <optional>
options.type Notification title
messagestring Notification message
durationnumber <optional>
handler Notification duration (override handler duration value)
iconlessboolean <optional>
false No icon flag
thickBorderstring <optional>
handler Notification border side (override handler side value)
closableboolean <optional>
true Make notification closable flag
stickyboolean <optional>
false Make notification sticky flag
renderToobject <optional>
handler Dom object to render the notification in
CBtitlestring <optional>
Callback Notification callback title
callbackfunction <optional>
Notification callback button
Returns:
number -The newly created notification ID
- Since:
- June 2018
-
static success(options) → {number}
-
Build a success notification
Parameters:
Name Type Description optionsobject The notification options object (see new() arguments since this is an abstraction of new())
Returns:
number -The newly created notification ID
- Since:
- June 2018
-
static warning(options) → {number}
-
Build a warning notification
Parameters:
Name Type Description optionsobject The notification options object (see new() arguments since this is an abstraction of new())
Returns:
number -The newly created notification ID
- Since:
- June 2018