diff --git a/src/Our.Umbraco.UiExamples/App_Plugins/uiexamples/alerts/alerts.controller.js b/src/Our.Umbraco.UiExamples/App_Plugins/uiexamples/alerts/alerts.controller.js new file mode 100644 index 0000000..45fe1de --- /dev/null +++ b/src/Our.Umbraco.UiExamples/App_Plugins/uiexamples/alerts/alerts.controller.js @@ -0,0 +1,55 @@ +(function () { + 'use strict'; + + function alertsController($scope, exampleResource, notificationsService) { + + var vm = this; + + function init() { + + vm.loading = true; + + vm.linkAway = exampleResource.linkAway; + + vm.alerts = [ + { type: "form", class: "alert alert-form", headline: "Form", message: "A message, displaying on a white background with a dark border.", style: "info" }, + { type: "info", class: "alert alert-info", headline: "Info", message: "An informational message, displaying on a blue background.", style: "action" }, + { type: "success", class: "alert alert-success", headline: "Success", message: "A success message, displaying on a green background.", style: "success" }, + { type: "warning", class: "alert alert-warning", headline: "Warning", message: "A warning message, displaying on an orange background.", style: "warning" }, + { type: "error", class: "alert alert-error", headline: "Error", message: "An error message, displaying on a red background.", style: "danger" }, + { type: "", class: "well", headline: "Well", message: "An informational message, displaying inset on a gray background.", style: "info" } + ]; + + vm.snippetNotification = `// To display a success notification. +notificationsService.success("Document Published", "hooraaaay for you!"); + +// To display an error notification. +notificationsService.error("Document Failed", "booooh"); + +// To display a custom notification, with sticky. +notificationsService.add({ headline: 'Custom notification', message: 'My custom notification message', type: 'info', sticky: true });`; + + vm.showNotification = showNotification; + vm.snippetAlert = snippetAlert; + }; + + function showNotification(item) { + notificationsService.add({ + headline: item.headline, + message: item.message, + type: item.type + }); + }; + + function snippetAlert(item) { + return `
The alerts and notifications can provide contextual feedback messages for typical user actions.
+The difference between alerts and notifications is that, an alert is a set of visual styles to display a feedback message, whereas a notification is a temporary feedback message that is displayed at the bottom of the screen.
+A notification is a contextual feedback message that appears at the bottom of the screen.
+ +The initialization of the umb-notifications
directive is done at page level, typically you will not need to this, as it is already added to the main CMS backoffice pages.
But if you do need to add the directive, this is the code snippet:
+The styling and types of the notifications are the same as the alerts (below). Use the buttons below to trigger the different types.
+ +The default timeout for a notification message before it disappears is 10 seconds.
+ +To use notifications in your own code, you will need to inject the notificationsService
into your AngularJS code.
An alert is a set of visual styles (e.g. CSS classes), that can be used to display feedback messages.
+ +