From c05efa8d7ae464235cf83d7c0956e42dc6974103 Mon Sep 17 00:00:00 2001 From: julieng Date: Sat, 2 Oct 2021 17:20:14 +0200 Subject: move *.html to *.md --- files/fr/web/api/notificationevent/index.html | 92 --------------------------- 1 file changed, 92 deletions(-) delete mode 100644 files/fr/web/api/notificationevent/index.html (limited to 'files/fr/web/api/notificationevent/index.html') diff --git a/files/fr/web/api/notificationevent/index.html b/files/fr/web/api/notificationevent/index.html deleted file mode 100644 index e46d5d4727..0000000000 --- a/files/fr/web/api/notificationevent/index.html +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: NotificationEvent -slug: Web/API/NotificationEvent -tags: - - API - - Experimental - - Interface - - Reference - - ServiceWorker -translation_of: Web/API/NotificationEvent ---- -
{{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")}}.

- -

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

- -

Constructeur

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

Propriétés

- -

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.
-
- -

Méthodes

- -

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")}}).

-
-
- -

Exemples

- -
self.addEventListener('notificationclick', function(event) {
-  console.log('Au clic sur la notification : ', event.notification.tag);
-  event.notification.close();
-
-  // On regarde ici si elle est déjà ouverte
-  // et si le focus est dessus
-  event.waitUntil(clients.matchAll({
-    type: "window"
-  }).then(function(clientList) {
-    for (var i = 0; i < clientList.length; i++) {
-      var client = clientList[i];
-      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")}}

-- cgit v1.2.3-54-g00ecf