UNPKG

10.4 kBMarkdownView Raw
1<!--
2# license: Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18-->
19
20# cordova-plugin-dialogs
21
22[![Build Status](https://travis-ci.org/apache/cordova-plugin-dialogs.svg)](https://travis-ci.org/apache/cordova-plugin-dialogs)
23
24このプラグインは、グローバル `navigator.notification` オブジェクトを介していくつかネイティブ ダイアログの UI 要素へのアクセスを提供します。
25
26オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。
27
28 document.addEventListener("deviceready", onDeviceReady, false);
29 function onDeviceReady() {
30 console.log(navigator.notification);
31 }
32
33
34## インストール
35
36 cordova plugin add cordova-plugin-dialogs
37
38
39## メソッド
40
41 * `navigator.notification.alert`
42 * `navigator.notification.confirm`
43 * `navigator.notification.prompt`
44 * `navigator.notification.beep`
45
46## navigator.notification.alert
47
48カスタムの警告またはダイアログ ボックスが表示されます。 ほとんどコルドバ ネイティブ] ダイアログ ボックスの使用この機能がいくつかのプラットフォームは通常小さいカスタマイズ可能なブラウザーの `警告` 機能を使用します。
49
50 navigator.notification.alert(message, alertCallback, [title], [buttonName])
51
52
53 * **メッセージ**: ダイアログ メッセージ。*(文字列)*
54
55 * **alertCallback**: 警告ダイアログが閉じられたときに呼び出すコールバック。*(機能)*
56
57 * **タイトル**: ダイアログのタイトル。*(文字列)*(省略可能、既定値は`Alert`)
58
59 * **buttonName**: ボタンの名前。*(文字列)*(省略可能、既定値は`OK`)
60
61### 例
62
63 function alertDismissed() {
64 // do something
65 }
66
67 navigator.notification.alert(
68 'You are the winner!', // message
69 alertDismissed, // callback
70 'Game Over', // title
71 'Done' // buttonName
72 );
73
74
75### サポートされているプラットフォーム
76
77 * アマゾン火 OS
78 * アンドロイド
79 * ブラックベリー 10
80 * Firefox の OS
81 * iOS
82 * Tizen
83 * Windows Phone 7 と 8
84 * Windows 8
85 * Windows
86
87### Windows Phone 7 と 8 癖
88
89 * 組み込みのブラウザー警告がない呼び出しを次のように 1 つをバインドすることができます `alert()` 、グローバル スコープで。
90
91 window.alert = navigator.notification.alert;
92
93
94 * 両方の `alert``confirm` は非ブロッキング呼び出し、結果は非同期的にのみ利用できます。
95
96### Firefox OS 互換:
97
98ネイティブ ブロック `window.alert()` と非ブロッキング `navigator.notification.alert()` があります。
99
100### ブラックベリー 10 癖
101
102`navigator.notification.alert ('text' コールバック 'title'、'text')` コールバック パラメーターは数 1 に渡されます。
103
104## navigator.notification.confirm
105
106カスタマイズ可能な確認のダイアログ ボックスが表示されます。
107
108 navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
109
110
111 * **メッセージ**: ダイアログ メッセージ。*(文字列)*
112
113 * **confirmCallback**: インデックス (1、2、または 3) を押されたボタンまたはダイアログ ボックスは、ボタンを押す (0) なしに解雇されたときに呼び出すコールバック。*(機能)*
114
115 * **タイトル**: ダイアログのタイトル。*(文字列)*(省略可能、既定値は`Confirm`)
116
117 * **buttonLabels**: ボタンのラベルを指定する文字列の配列。*(配列)*(省略可能、既定値は [ `OK,Cancel` ])
118
119### confirmCallback
120
121`confirmCallback` は、いずれかの確認ダイアログ ボックスでボタンを押したときに実行します。
122
123コールバックは、引数 `buttonIndex` *(番号)* は、押されたボタンのインデックス。 インデックスがインデックス 1 ベースので、値は `1``2``3` などに注意してください。
124
125### 例
126
127 function onConfirm(buttonIndex) {
128 alert('You selected button ' + buttonIndex);
129 }
130
131 navigator.notification.confirm(
132 'You are the winner!', // message
133 onConfirm, // callback to invoke with index of button pressed
134 'Game Over', // title
135 ['Restart','Exit'] // buttonLabels
136 );
137
138
139### サポートされているプラットフォーム
140
141 * アマゾン火 OS
142 * アンドロイド
143 * ブラックベリー 10
144 * Firefox の OS
145 * iOS
146 * Tizen
147 * Windows Phone 7 と 8
148 * Windows 8
149 * Windows
150
151### Windows Phone 7 と 8 癖
152
153 * 組み込みブラウザーの機能はありません `window.confirm` が割り当てることによってバインドすることができます。
154
155 window.confirm = navigator.notification.confirm;
156
157
158 * 呼び出しを `alert``confirm` では非ブロッキング、結果は非同期的にのみ使用できます。
159
160### Windows の癖
161
162 * Windows8/8.1 の MessageDialog インスタンスを 3 つ以上のボタンを追加することはできません。
163
164 * Windows Phone 8.1 に 2 つ以上のボタンを持つダイアログを表示することはできません。
165
166### Firefox OS 互換:
167
168ネイティブ ブロック `window.confirm()` と非ブロッキング `navigator.notification.confirm()` があります。
169
170## navigator.notification.prompt
171
172ブラウザーの `プロンプト` 機能より詳細にカスタマイズはネイティブのダイアログ ボックスが表示されます。
173
174 navigator.notification.prompt(message, promptCallback, [title], [buttonLabels], [defaultText])
175
176
177 * **メッセージ**: ダイアログ メッセージ。*(文字列)*
178
179 * **promptCallback**: インデックス (1、2、または 3) を押されたボタンまたはダイアログ ボックスは、ボタンを押す (0) なしに解雇されたときに呼び出すコールバック。*(機能)*
180
181 * **title**: タイトル *(String)* (省略可能、既定 `プロンプト` ダイアログ)
182
183 * **buttonLabels**: ボタンのラベル *(配列)* (省略可能、既定値 `["OK"、「キャンセル」]` を指定する文字列の配列)
184
185 * **defaultText**: 既定テキスト ボックスの入力値 (`文字列`) (省略可能、既定: 空の文字列)
186
187### promptCallback
188
189`promptCallback` は、プロンプト ダイアログ ボックス内のボタンのいずれかを押したときに実行します。コールバックに渡される `results` オブジェクトには、次のプロパティが含まれています。
190
191 * **buttonIndex**: 押されたボタンのインデックス。*(数)*インデックスがインデックス 1 ベースので、値は `1``2``3` などに注意してください。
192
193 * **input1**: プロンプト ダイアログ ボックスに入力したテキスト。*(文字列)*
194
195### 例
196
197 function onPrompt(results) {
198 alert("You selected button number " + results.buttonIndex + " and entered " + results.input1);
199 }
200
201 navigator.notification.prompt(
202 'Please enter your name', // message
203 onPrompt, // callback to invoke
204 'Registration', // title
205 ['Ok','Exit'], // buttonLabels
206 'Jane Doe' // defaultText
207 );
208
209
210### サポートされているプラットフォーム
211
212 * アマゾン火 OS
213 * アンドロイド
214 * Firefox の OS
215 * iOS
216 * Windows Phone 7 と 8
217 * Windows 8
218 * Windows
219
220### Android の癖
221
222 * Android は最大 3 つのボタンをサポートしているし、それ以上無視します。
223
224 * アンドロイド 3.0 と後、ホロのテーマを使用するデバイスを逆の順序でボタンが表示されます。
225
226### Windows の癖
227
228 * Windows プロンプト ダイアログは html ベースのようなネイティブ api の不足のためです。
229
230### Firefox OS 互換:
231
232ネイティブ ブロック `window.prompt()` と非ブロッキング `navigator.notification.prompt()` があります。
233
234## navigator.notification.beep
235
236デバイス サウンドをビープ音を再生します。
237
238 navigator.notification.beep(times);
239
240
241 * **times**: ビープ音を繰り返す回数。*(数)*
242
243### 例
244
245 // Beep twice!
246 navigator.notification.beep(2);
247
248
249### サポートされているプラットフォーム
250
251 * アマゾン火 OS
252 * アンドロイド
253 * ブラックベリー 10
254 * iOS
255 * Tizen
256 * Windows Phone 7 と 8
257 * Windows 8
258
259### アマゾン火 OS 癖
260
261 * アマゾン火 OS デフォルト **設定/表示 & サウンド** パネルの下に指定した **通知音** を果たしています。
262
263### Android の癖
264
265 * アンドロイド デフォルト **通知着信音** **設定/サウンド & ディスプレイ** パネルの下に指定を果たしています。
266
267### Windows Phone 7 と 8 癖
268
269 * コルドバ分布からジェネリック ビープ音ファイルに依存します。
270
271### Tizen の癖
272
273 * Tizen は、メディア API 経由でオーディオ ファイルを再生してビープ音を実装します。
274
275 * ビープ音ファイル短い、`sounds` アプリケーションのルート ディレクトリのサブディレクトリである必要があり。、`beep.wav` という名前である必要があります。.
\No newline at end of file