import {Notification} from 'aurelia-notification';
Set a new configuration based on current configuration. The same options as in the plugin configuration are available. The default configuration for this plugin is
{
translate: true, // translate messages {true/false}.
// translate: true needs aurelia-i18n to be configured
defaults: {}, // defaults for all notifications are humane-js defaults
notifications: { // default methods definitions
note: {}, // method name and their defaults
success: {addnCls: 'success'},
error: {addnCls: 'error'},
info: {addnCls: 'info'}
}
}
The notifications object accepts methodName:'addnClsName'
or methodName:optionsObject
. defaults.baseCls sets the base css class for humane-js notifications. The default of humane-js is {baseCls: 'humane'}. For the available defaults/options see humane-js.
Parameter | Type | Description |
---|---|---|
config | object | New config based on the current config |
The configuration object
this.notification.configure(
notifications: {
success: 'smallSuccess', // converts to {addnCls: 'smallSuccess'}
largeError: {addnCls:'largeError'}
}
);
this.notification.largeError('Biggy');
Set the base css class for the notifications.
Parameter | Type | Description |
---|---|---|
message | string | The base css class for the notifications. |
The new baseCls
this.setBaseClass('humane-libnotify');
Set the container for the notifications.
Parameter | Type | Description |
---|---|---|
message | DOM.node | The container for the notifications. |
The new container
this.setContainer($('.content'));
Notify using humane.log. Depending on options and defaults, the message gets translated using i18n if available.
Parameter | Type | Description |
---|---|---|
message | string/array | The message as string or array of strings |
options | object | Options for this particular notification |
defaults | object | Defaults for this type of notifications |
Promise.resolve when finished
this.notification.log('Color will change when finished')
.then(()=>document.body.style.backgroundColor='#a66000');
As per the default configuration, method shortcuts for .log with addnCls defaulting to '', success', 'error' or 'info' resp. to the addnCls set in the plugin configuration.
Parameter | Type | Description |
---|---|---|
message | string/array | The message as string or array of strings |
options | object | Additional options for humane-js |
Promise.resolve when finished
this.notification.success('Yippy!!');
this.notification.error(['Darn','Not available']);
this.notification.info('Still there?', {waitForMove: true})
then(()=>this.notification.info('Oh, you are!'));
Sets a shortcut for .log with defaults.
Parameter | Type | Description |
---|---|---|
defaults | object | Default options for the returned .log function |
A .log(message[, options[, defaults]]) function with defaults applied.
let mylog = this.notification.spawn({addCls:'alert'});
mylog('This is a translated custom alert')
.then(()=>console.log('alert closed'));
Force remove the current notification
Promise.resolve when finished
this.notification.remove();