@@ -71,6 +71,14 @@ define(function (require, exports, module) {
7171 const NOTIFICATION_TYPE_ARROW = "arrow" ,
7272 NOTIFICATION_TYPE_TOAST = "toast" ;
7373
74+ const NOTIFICATION_STYLES_CSS_CLASS = {
75+ INFO : "style-info" ,
76+ WARNING : "style-warning" ,
77+ SUCCESS : "style-success" ,
78+ ERROR : "style-error" ,
79+ DANGER : "style-danger"
80+ } ;
81+
7482 const CLOSE_REASON = {
7583 TIMEOUT : 'closeTimeout' ,
7684 CLICK_DISMISS : 'clickDismiss' ,
@@ -305,19 +313,22 @@ define(function (require, exports, module) {
305313 *
306314 * @param {string } title The title for the notification.
307315 * @param {string|Element } template A string template or HTML Element to use as the dialog HTML.
308- * @param {{dismissOnClick, autoCloseTimeS} } [options] optional, supported
316+ * @param {{dismissOnClick, autoCloseTimeS, toastStyle } } [options] optional, supported
309317 * * options are:
310318 * * `autoCloseTimeS` - Time in seconds after which the notification should be auto closed. Default is never.
311319 * * `dismissOnClick` - when clicked, the notification is closed. Default is true(dismiss).
320+ * * `toastStyle` - To style the toast notification for error, warning, info etc. Can be
321+ * one of `NotificationUI.NOTIFICATION_STYLES_CSS_CLASS.*` or your own css class name.
312322 * @return {Notification } Object with a done handler that resolves when the notification closes.
313323 * @type {function }
314324 */
315325 function createToastFromTemplate ( title , template , options = { } ) {
316326 options . dismissOnClick = options . dismissOnClick === undefined ? true : options . dismissOnClick ;
317327 notificationWidgetCount ++ ;
318328 const widgetID = `notification-toast-${ notificationWidgetCount } ` ,
319- $NotificationPopup = $ ( Mustache . render ( ToastPopupHtml ,
320- { id : widgetID , title : title } ) ) ;
329+ $NotificationPopup = $ ( Mustache . render ( ToastPopupHtml , { id : widgetID , title : title ,
330+ containerStyle : NOTIFICATION_STYLES_CSS_CLASS [ options . toastStyle ]
331+ || options . toastStyle || NOTIFICATION_STYLES_CSS_CLASS . INFO } ) ) ;
321332 $NotificationPopup . find ( ".notification-dialog-content" )
322333 . append ( $ ( template ) ) ;
323334
@@ -354,4 +365,5 @@ define(function (require, exports, module) {
354365 exports . createFromTemplate = createFromTemplate ;
355366 exports . createToastFromTemplate = createToastFromTemplate ;
356367 exports . CLOSE_REASON = CLOSE_REASON ;
368+ exports . NOTIFICATION_STYLES_CSS_CLASS = NOTIFICATION_STYLES_CSS_CLASS ;
357369} ) ;
0 commit comments