diff options
| author | beccabroek <beccabroek@gmail.com> | 2019-02-05 15:43:17 -0600 |
|---|---|---|
| committer | beccabroek <beccabroek@gmail.com> | 2019-02-06 14:17:01 -0600 |
| commit | 27ce84d247a41288228713342d4e7745d8806eba (patch) | |
| tree | 67c9e1c3c7071bfdd7d11194a7031a014610afca /app/common/services | |
| parent | a09cc2da1b3a9bad0eaf34fbfdec8a3ee32d47f8 (diff) | |
| download | phosphor-webui-27ce84d247a41288228713342d4e7745d8806eba.tar.gz phosphor-webui-27ce84d247a41288228713342d4e7745d8806eba.zip | |
Add role alert to toasts
For accessibility reasons, 'role="alert" is required for toast
messages. This notifies screen readers that an error or success
message has appeared. Adds a service layer for toast messages
that adds the role attribute to the message.
Change-Id: Ic4dbf5556337eea589de5692c1b4c3323e771813
Signed-off-by: beccabroek <beccabroek@gmail.com>
Diffstat (limited to 'app/common/services')
| -rw-r--r-- | app/common/services/toastService.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/common/services/toastService.js b/app/common/services/toastService.js new file mode 100644 index 0000000..c199e96 --- /dev/null +++ b/app/common/services/toastService.js @@ -0,0 +1,28 @@ +/** + * data service + * + * @module app/common/services/toastService + * @exports toastService + * @name toastService + + */ + +window.angular && (function(angular) { + 'use strict'; + + angular.module('app.common.services').service('toastService', [ + 'ngToast', '$sce', + function(ngToast, $sce) { + this.error = function(message) { + var errorMessage = $sce.trustAsHtml( + '<div role="alert"><b>Error</b><br>' + message + '</div>'); + ngToast.create({className: 'danger', content: errorMessage}); + }; + this.success = function(message) { + var successMessage = $sce.trustAsHtml( + '<div role="alert"><b>Success!</b><br>' + message + '</div>'); + ngToast.create({className: 'success', content: successMessage}); + }; + } + ]); +})(window.angular); |

