define([
'base/js/ui/UiUtils',
'ui/js/api/Notification'
], function (
UiUtils,
Notification
) {
'use strict';
/**
* Application UI support.
*
* @AbcsAPI stable
* @version 15.4.5
*
* @exports api/js/UI
*/
var UI = function () {
AbcsLib.throwStaticClassError();
};
/**
* Shows a notification.
*
* @AbcsAPI stable
* @version 15.4.5
* @param {ui/js/api/Notification} notification notification to display to user
* @returns {module:api/js/UI.Closeable}
*
* @example
* <caption>Creates and shows simple INFO level message in the UI</caption>
* //create and show a simple INFO message
* UI.showNotification(UI.Notification.create({
* message: 'I\'m informing you ...'
* });
* @example
* <caption>Creates and shows Notification message. Once it's shown it's closed from the code.</caption>
* //create and show a message
* var notification = UI.Notification.create({
* message: 'Ahoy',
* level: UI.Notification.Level.SUCCESS
* });
* var closeHandler = UI.showNotification(notification);
* //explicitly close it later
* closeHandler.close();
*/
UI.showNotification = function (notification) {
var message = notification.getMessage();
switch (notification.getLevel()) {
case Notification.Level.SUCCESS:
return UiUtils.showSuccessNote(message);
case Notification.Level.INFO:
return UiUtils.showInfoNote(message);
case Notification.Level.WARNING:
return UiUtils.showWarningNote(message);
case Notification.Level.ERROR:
return UiUtils.showErrorNote(message);
default:
Logger.get('api/js/UI').info('Unknown notification level: ' + notification.getLevel());
}
};
/**
* Notifications module.
*
* @AbcsAPI stable
* @version 15.4.5
* @type {ui/js/api/Notification}
*/
UI.Notification = Notification;
/**
* API object allowing client to perform particular operation.
*
* <p>
* Object providing method which can close the opened notification. This object
* is obtained after showing Notification, see {@link module:api/js/UI.showNotification UI.showNotification}
* for details.
* </p>
*
* @AbcsAPI stable
* @memberof module:api/js/UI
* @objectLiteral
*
*
* @see {@link module:api/js/UI UI}
* @see {@link module:api/js/UI.showNotification UI.showNotification}
*/
var Closeable = function() {
};
/**
* Close the notification message.
*
* @AbcsAPI stable
* @version 15.4.5
*/
Closeable.close = function() {
};
return UI;
});