From 1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde Mon Sep 17 00:00:00 2001 From: julieng Date: Sat, 2 Oct 2021 17:20:24 +0200 Subject: convert content to md --- files/fr/web/api/notificationevent/index.md | 88 +++++++++++------------------ 1 file changed, 34 insertions(+), 54 deletions(-) (limited to 'files/fr/web/api/notificationevent') diff --git a/files/fr/web/api/notificationevent/index.md b/files/fr/web/api/notificationevent/index.md index e46d5d4727..0b2803c583 100644 --- a/files/fr/web/api/notificationevent/index.md +++ b/files/fr/web/api/notificationevent/index.md @@ -9,44 +9,37 @@ tags: - ServiceWorker translation_of: Web/API/NotificationEvent --- -
{{APIRef("Service Workers API")}}{{SeeCompatTable}}
+{{APIRef("Service Workers API")}}{{SeeCompatTable}} -

L'interface NotificationEvent représente un évènement de clic pour une notification et qui est dispatché vers le {{domxref("ServiceWorkerGlobalScope")}} d'un {{domxref("ServiceWorker")}}.

+L'interface **`NotificationEvent`** représente un évènement de clic pour une notification et qui est dispatché vers le {{domxref("ServiceWorkerGlobalScope")}} d'un {{domxref("ServiceWorker")}}. -

Cette interface hérite de l'interface {{domxref("ExtendableEvent")}}.

+Cette interface hérite de l'interface {{domxref("ExtendableEvent")}}. -

Constructeur

+## Constructeur -
-
{{domxref("NotificationEvent.NotificationEvent()")}}
-
Cette méthode permet de créer un nouvel objet NotificationEvent.
-
+- {{domxref("NotificationEvent.NotificationEvent()")}} + - : Cette méthode permet de créer un nouvel objet `NotificationEvent`. -

Propriétés

+## Propriétés -

Cet objet hérite de propriétés grâce à son ancêtre : {{domxref("Event")}}.

+_Cet objet hérite de propriétés grâce à son ancêtre : {{domxref("Event")}}_. -
-
{{domxref("NotificationEvent.notification")}} {{readonlyInline}}
-
Cette propriété renvoie un objet {{domxref("Notification")}} représentant la notification sur laquelle on a cliqué pour déclencher l'évènement.
-
{{domxref("NotificationEvent.action")}} {{readonlyinline}}
-
Cette propriété renvoie une chaîne de caractères identifiant le bouton de la notification sur lequel l'utilisateur a cliqué. Cette valeur sera {{jsxref("undefined")}} si l'utilisateur a cliqué autre part que sur le bouton pour la notification ou si la notification ne possède pas de bouton.
-
+- {{domxref("NotificationEvent.notification")}} {{readonlyInline}} + - : Cette propriété renvoie un objet {{domxref("Notification")}} représentant la notification sur laquelle on a cliqué pour déclencher l'évènement. +- {{domxref("NotificationEvent.action")}} {{readonlyinline}} + - : Cette propriété renvoie une chaîne de caractères identifiant le bouton de la notification sur lequel l'utilisateur a cliqué. Cette valeur sera {{jsxref("undefined")}} si l'utilisateur a cliqué autre part que sur le bouton pour la notification ou si la notification ne possède pas de bouton. -

Méthodes

+## Méthodes -

Cet objet hérite de méthodes grâce à son parent {{domxref("ExtendableEvent")}}.

+_Cet objet hérite de méthodes grâce à son parent_ _{{domxref("ExtendableEvent")}}_. -
-
{{domxref("ExtendableEvent.waitUntil", "ExtendableEvent.waitUntil()")}}
-
-

Cette méthode allonge la durée de vie de l'évènement. Elle est conçue pour être appelée dans le gestionnaire d'évènement {{event("install")}} lors de l'installation (cf. {{domxref("ServiceWorkerRegistration.installing")}}) du worker et dans le gestionnaire d'évènement {{event("active")}} pour le worker actif (cf. {{domxref("ServiceWorkerRegistration.active")}}).

-
-
+- {{domxref("ExtendableEvent.waitUntil", "ExtendableEvent.waitUntil()")}} + - : Cette méthode allonge la durée de vie de l'évènement. Elle est conçue pour être appelée dans le gestionnaire d'évènement {{event("install")}} lors de l'installation (cf. {{domxref("ServiceWorkerRegistration.installing")}}) du _worker_ et dans le gestionnaire d'évènement {{event("active")}} pour le _worker_ actif (cf. {{domxref("ServiceWorkerRegistration.active")}}). -

Exemples

+## Exemples -
self.addEventListener('notificationclick', function(event) {
+```js
+self.addEventListener('notificationclick', function(event) {
   console.log('Au clic sur la notification : ', event.notification.tag);
   event.notification.close();
 
@@ -55,38 +48,25 @@ translation_of: Web/API/NotificationEvent
   event.waitUntil(clients.matchAll({
     type: "window"
   }).then(function(clientList) {
-    for (var i = 0; i < clientList.length; i++) {
+    for (var i = 0; i < clientList.length; i++) {
       var client = clientList[i];
-      if (client.url == '/' && 'focus' in client)
+      if (client.url == '/' && 'focus' in client)
         return client.focus();
     }
     if (clients.openWindow)
       return clients.openWindow('/');
   }));
 });
-
- -

Spécifications

- - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('Web Notifications','#notificationevent','NotificationEvent')}}{{Spec2('Web Notifications')}} 
- -
-

Note : Cette interface est définie au sein de l'API Notifications, mais on y accède via {{domxref("ServiceWorkerGlobalScope")}}.

-
- -

Compatibilité des navigateurs

- -

{{Compat("api.NotificationEvent")}}

+``` + +## Spécifications + +| Spécification | État | Commentaires | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------------ | +| {{SpecName('Web Notifications','#notificationevent','NotificationEvent')}} | {{Spec2('Web Notifications')}} |   | + +> **Note :** Cette interface est définie au sein de [l'API Notifications](/fr/docs/Web/API/Notifications_API), mais on y accède via {{domxref("ServiceWorkerGlobalScope")}}. + +## Compatibilité des navigateurs + +{{Compat("api.NotificationEvent")}} -- cgit v1.2.3-54-g00ecf