|
23 | 23 | * @returns {Object} The service instance
|
24 | 24 | *
|
25 | 25 | * @description
|
26 |
| - * The web notification service wraps the HTML 5 Web Notifications API as an angular service.<br> |
27 |
| - * See [simple-web-notification](https://github.com/sagiegurari/simple-web-notification/blob/master/docs/api.md) for detailed API. |
28 |
| - * |
29 |
| - * @example |
30 |
| - * ```js |
31 |
| - * angular.module('exampleApp').directive('showButton', ['webNotification', function (webNotification) { |
32 |
| - * return { |
33 |
| - * link: function (scope, element) { |
34 |
| - * element.on('click', function onClick() { |
35 |
| - * webNotification.showNotification('Example Notification', { |
36 |
| - * body: 'Notification Text...', |
37 |
| - * icon: 'my-icon.ico', |
38 |
| - * onClick: function onNotificationClicked() { |
39 |
| - * console.log('Notification clicked.'); |
40 |
| - * }, |
41 |
| - * autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function) |
42 |
| - * }, function onShow(error, hide) { |
43 |
| - * if (error) { |
44 |
| - * window.alert('Unable to show notification: ' + error.message); |
45 |
| - * } else { |
46 |
| - * console.log('Notification Shown.'); |
47 |
| - * |
48 |
| - * setTimeout(function hideNotification() { |
49 |
| - * console.log('Hiding notification....'); |
50 |
| - * hide(); //manually close the notification (you can skip this if you use the autoClose option) |
51 |
| - * }, 5000); |
52 |
| - * } |
53 |
| - * }); |
54 |
| - * }); |
55 |
| - * } |
56 |
| - * }; |
57 |
| - * }]); |
58 |
| - * ``` |
| 26 | + * The web notification service wraps the HTML 5 Web Notifications API as an angular service. |
59 | 27 | */
|
60 | 28 | webNotification.factory('webNotification', function onCreateService() {
|
| 29 | + /** |
| 30 | + * Shows the notification based on the provided input.<br> |
| 31 | + * The callback invoked will get an error object (in case of an error, null in |
| 32 | + * case of no errors) and a 'hide' function which can be used to hide the notification. |
| 33 | + * |
| 34 | + * @function |
| 35 | + * @memberof! webNotification |
| 36 | + * @alias webNotification.showNotification |
| 37 | + * @public |
| 38 | + * @param {String} [title] - The notification title text (defaulted to empty string if null is provided) |
| 39 | + * @param {Object} [options] - Holds the notification data (web notification API spec for more info) |
| 40 | + * @param {String} [options.icon=/favicon.ico] - The notification icon (defaults to the website favicon.ico) |
| 41 | + * @param {Number} [options.autoClose] - Auto closes the notification after the provided amount of millies (0 or undefined for no auto close) |
| 42 | + * @param {function} [options.onClick] - An optional onclick event handler |
| 43 | + * @param {ShowNotificationCallback} [callback] - Called after the show is handled. |
| 44 | + * @example |
| 45 | + * ```js |
| 46 | + * webNotification.showNotification('Example Notification', { |
| 47 | + * body: 'Notification Text...', |
| 48 | + * icon: 'my-icon.ico', |
| 49 | + * onClick: function onNotificationClicked() { |
| 50 | + * console.log('Notification clicked.'); |
| 51 | + * }, |
| 52 | + * autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function) |
| 53 | + * }, function onShow(error, hide) { |
| 54 | + * if (error) { |
| 55 | + * window.alert('Unable to show notification: ' + error.message); |
| 56 | + * } else { |
| 57 | + * console.log('Notification Shown.'); |
| 58 | + * |
| 59 | + * setTimeout(function hideNotification() { |
| 60 | + * console.log('Hiding notification....'); |
| 61 | + * hide(); //manually close the notification (you can skip this if you use the autoClose option) |
| 62 | + * }, 5000); |
| 63 | + * } |
| 64 | + * }); |
| 65 | + * ``` |
| 66 | + */ |
| 67 | + |
61 | 68 | return webNotificationAPI;
|
62 | 69 | });
|
63 | 70 | }(window.webNotification));
|
0 commit comments