From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../ja/web/api/notificationevent/action/index.html | 64 ++++++++++++++ files/ja/web/api/notificationevent/index.html | 97 ++++++++++++++++++++++ .../api/notificationevent/notification/index.html | 75 +++++++++++++++++ .../notificationevent/notificationevent/index.html | 64 ++++++++++++++ 4 files changed, 300 insertions(+) create mode 100644 files/ja/web/api/notificationevent/action/index.html create mode 100644 files/ja/web/api/notificationevent/index.html create mode 100644 files/ja/web/api/notificationevent/notification/index.html create mode 100644 files/ja/web/api/notificationevent/notificationevent/index.html (limited to 'files/ja/web/api/notificationevent') diff --git a/files/ja/web/api/notificationevent/action/index.html b/files/ja/web/api/notificationevent/action/index.html new file mode 100644 index 0000000000..0f1f7bf62f --- /dev/null +++ b/files/ja/web/api/notificationevent/action/index.html @@ -0,0 +1,64 @@ +--- +title: NotificationEvent.action +slug: Web/API/NotificationEvent/action +tags: + - API + - Experimental + - NotificationEvent + - Notifications + - Property + - Reference + - Service Workers + - ServiceWorker + - action + - プロパティ + - 通知 +translation_of: Web/API/NotificationEvent/action +--- +

{{APIRef("Web Notifications")}}

+ +

ユーザーがクリックした通知ボタンの文字列 ID を返します。ユーザーがアクションボタン以外の場所で通知をクリックした場合、または通知にボタンがない場合、この値は空の文字列を返します。通知 ID は、アクション配列属性を介した通知の作成中に設定され、通知が置き換えられない限り変更することはできません。

+ +

返値

+ +

{{domxref("DOMString")}} オブジェクト。

+ +

+ +
self.registration.showNotification("New articles available", {
+  actions: [{action: "get", title: "Get now."}]
+});
+
+self.addEventListener('notificationclick', function(event) {
+  event.notification.close();
+  if (event.action === 'get') {
+    synchronizeReader();
+  } else {
+    clients.openWindow("/reader");
+  }
+}, false);
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Web Notifications','#dom-notification-actions','action')}}{{Spec2('Web Notifications')}}Living standard
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/notificationevent/index.html b/files/ja/web/api/notificationevent/index.html new file mode 100644 index 0000000000..64fa156443 --- /dev/null +++ b/files/ja/web/api/notificationevent/index.html @@ -0,0 +1,97 @@ +--- +title: NotificationEvent +slug: Web/API/NotificationEvent +tags: + - API + - Interface + - NotificationEvent + - Reference + - Service Workers + - ServiceWorker +translation_of: Web/API/NotificationEvent +--- +

{{APIRef("Web Notifications")}}

+ +

{{domxref("ServiceWorkerGlobalScope.onnotificationclick", "onnotificationclick")}} ハンドラーに渡される引数である NotificationEvent インターフェイスは、 {{domxref("ServiceWorker")}} の {{domxref("ServiceWorkerGlobalScope")}} で配信される通知クリックイベントを表します。

+ +

このインターフェイスは {{domxref("ExtendableEvent")}} インターフェイスを継承しています。

+ +

コンストラクター

+ +
+
{{domxref("NotificationEvent.NotificationEvent","NotificationEvent()")}}
+
新しい NotificationEvent オブジェクトを作成します。
+
+ +

プロパティ

+ +

祖先である {{domxref("Event")}} からプロパティを継承しています。

+ +
+
{{domxref("NotificationEvent.notification")}} {{readonlyInline}}
+
イベントを発生させるためにクリックされた通知を表す {{domxref("Notification")}} オブジェクトを返します。
+
{{domxref("NotificationEvent.action")}} {{readonlyinline}}
+
ユーザーがクリックした通知ボタンの文字列 ID を返します。ユーザーがアクションボタン以外の場所で通知をクリックした場合、または通知にボタンがない場合、この値は空の文字列を返します。
+
+ +

メソッド

+ +

親の {{domxref("ExtendableEvent")}} からメソッドを継承しています。

+ +
+
{{domxref("ExtendableEvent.waitUntil", "ExtendableEvent.waitUntil()")}}
+
+

イベントの存続期間を延長します。作業が進行中であることをブラウザーに伝えます。

+
+
+ +

+ +
self.addEventListener('notificationclick', function(event) {
+  console.log('On notification click: ', event.notification.tag);
+  event.notification.close();
+
+  // これは、現在のページが既に開いているかどうかを確認し、
+  // そうならばフォーカスします
+  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('/');
+  }));
+});
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Web Notifications','#notificationevent','NotificationEvent')}}{{Spec2('Web Notifications')}}Living standard.
+ +
+

: このインターフェイスは Notifications API で定義されていますが、{{domxref("ServiceWorkerGlobalScope")}} を介してアクセスします。

+
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/notificationevent/notification/index.html b/files/ja/web/api/notificationevent/notification/index.html new file mode 100644 index 0000000000..b27d50a6f3 --- /dev/null +++ b/files/ja/web/api/notificationevent/notification/index.html @@ -0,0 +1,75 @@ +--- +title: NotificationEvent.notification +slug: Web/API/NotificationEvent/notification +tags: + - API + - Experimental + - NotificationEvent + - Notifications + - Property + - Reference + - Service Workers + - ServiceWorker + - プロパティ + - 通知 +translation_of: Web/API/NotificationEvent/notification +--- +

{{APIRef("Web Notifications")}}

+ +

notification は {{domxref("NotificationEvent")}} インターフェイスの読取専用プロパティで、クリックされてイベントを発行した {{domxref("Notification")}} のインスタンスを返します。 {{domxref("Notification")}} は tagdata 属性など、 Notification のインスタンス化時に設定された多くのプロパティへの読み取り専用アクセスを提供しており、あとで notificationclick イベントで使用するための情報を保存することができます。

+ +

返値

+ +

{{domxref("Notification")}} オブジェクト。

+ +

+ +
self.addEventListener('notificationclick', function(event) {
+  console.log('On notification click');
+
+  // Data can be attached to the notification so that you
+  // can process it in the notificationclick handler.
+  console.log('Notification Tag:', event.notification.tag);
+  console.log('Notification Data:', event.notification.data);
+  event.notification.close();
+
+  // This looks to see if the current is already open and
+  // focuses if it is
+  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('/');
+  }));
+});
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Web Notifications','#dom-notificationevent-notification','notification')}}{{Spec2('Web Notifications')}}Living standard
+ +

ブラウザーの互換性

+ + + +

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

diff --git a/files/ja/web/api/notificationevent/notificationevent/index.html b/files/ja/web/api/notificationevent/notificationevent/index.html new file mode 100644 index 0000000000..ce6cd34424 --- /dev/null +++ b/files/ja/web/api/notificationevent/notificationevent/index.html @@ -0,0 +1,64 @@ +--- +title: NotificationEvent.NotificationEvent() +slug: Web/API/NotificationEvent/NotificationEvent +tags: + - API + - Constructor + - Experimental + - NotificationEvent + - Notifications + - Reference + - Service Workers + - ServiceWorker + - コンストラクター + - 通知 +translation_of: Web/API/NotificationEvent/NotificationEvent +--- +

{{APIRef("Web Notifications")}}{{draft}}

+ +

NotificationEvent() コンストラクターは、新しい {{domxref("NotificationEvent")}} オブジェクトを生成します。

+ +

構文

+ +
var myNotificationEvent = new NotificationEvent(type, NotificationEventInit);
+ +

引数

+ +
+
type
+
TBD
+
NotificationEventInit {{optional_inline}}
+
イベントが配信される通知として使用される {{domxref("Notification")}} オブジェクトを含む辞書オブジェクト。この仕様書の後の草稿では、このパラメータはオプションではありません。
+
+ +

+ +
var n = new Notification('Hello');
+var init = { notification: n };
+var myNotificationEvent = new NotificationEvent(type, init);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Web Notifications','#dom-notificationevent-notificationevent','NotificationEvent() constructor')}}{{Spec2('Web Notifications')}}Living standard
+ +

ブラウザーの互換性

+ + + +

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

-- cgit v1.2.3-54-g00ecf