SHNotifications

Adds the ability to dispatch notifications from anywhere within the application. Wrap the objects to be dispatched in an array to show multiple notifications at once.
Source:
SHNotifications.add(
     {
         type: 'success'
         message: 'Success message here.'
     }
);

Methods

(static) add(data) → {void}

Adds a notification to the queue.
Source:
Parameters:
Name Type Description
data Object The data to pass to the notification.
Properties
Name Type Attributes Default Description
message String The message to display inside the notification.
type String <optional>
The type of notification. ('success', 'error', 'warning')
duration Integer <optional>
3000 The time (in ms) to show the notification for.
showClose Boolean <optional>
true Whether to show the close button.
autoClose Boolean <optional>
true Whether to automatically close the notification after duration.
cookie Object <optional>
A cookie that, if present, only shows the notification once.
Properties
Name Type Attributes Description
name String The name of the cookie.
expires Integer | Date <optional>
The number of days (Integer) or the date (Date) that determines the lifetime of the cookie.
buttons Array.<Object> <optional>
Adds buttons to the notification.
Properties
Name Type Attributes Description
displayClass String The class to add to the button. ('Button' or 'Button-link')
clickClass String A unique class to this notification which can differentiate this button from others.
label String The button label.
callback function The method to call when the button is clicked.
callbackParams Array <optional>
Parameters to pass to the callback method.
Returns:
Type
void
SHNotifications.add(
     {
         type: 'success'
         message: 'Success message here.'
         showClose: false,
         autoClose: false,
         duration: 2000,
         cookie: {
             name: 'nameOfCookie',
             expires: 1
         },
         buttons: [
             {
                 displayClass: 'Button',
                 clickClass: 'btn-label-1',
                 label: 'Label 1',
                 callback: cb,
                 callbackParams: [true, 'hello']
             },
             {
                 displayClass: 'Button-link',
                 clickClass: 'btn-label-2',
                 label: 'Label 2',
                 callback: cb2,
                 callbackParams: [this]
             }
         ]
     }
);