Skip to content

Commit d0d7a64

Browse files
committed
article translated
1 parent f2023a4 commit d0d7a64

File tree

1 file changed

+41
-42
lines changed
  • 1-js/02-first-steps/09-alert-prompt-confirm

1 file changed

+41
-42
lines changed
Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,108 @@
1-
# Interaction: alert, prompt, confirm
1+
# Interação: alert, prompt, confirm
22

3-
This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks.
4-
5-
But we'll still be using the browser as our demo environment, so we should know at least a few of its user-interface functions. In this chapter, we'll get familiar with the browser functions `alert`, `prompt` and `confirm`.
3+
Esta parte do tutorial tem como objetivo cobrir o JavaScript "como é ", sem ajustes específicos de ambiente.
4+
Mas ainda estaremos usando o navegador como nosso ambiente de demostração, portanto devemos conhecer pelo menos algumas de suas funções de interface. Neste capítulo, familiazaremos com as funções do navegador `alert`, `prompt` e `confirm`.
65

76
## alert
87

9-
Syntax:
8+
Sintaxe:
109

1110
```js
12-
alert(message);
11+
alert(mensagem);
1312
```
1413

15-
This shows a message and pauses script execution until the user presses "OK".
14+
mostrará uma mensagem até o usuário pressionar "OK".
1615

17-
For example:
16+
Por exemplo:
1817

1918
```js run
20-
alert("Hello");
19+
alert("Ola");
2120
```
2221

23-
The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc. until they have dealt with the window. In this case -- until they press "OK".
2422

23+
A mini-janela com a mensagem é chamada *modal view*. A palavra "modal" significa que o visitante não pode interagir com o resto da página, pressionar outros botões, etc. Até que ele tenha lidado com a janela. Nesse caso -- até pressionar "OK"
2524
## prompt
2625

27-
The function `prompt` accepts two arguments:
26+
A função `prompt` aceita dois argumentos
2827

2928
```js no-beautify
3029
result = prompt(title, [default]);
3130
```
3231

33-
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/CANCEL.
32+
Mostra uma janela modal com mensagem de texto, um campo de entrada para o visitante, e os botões OK/CANCEL
33+
3434

3535
`title`
36-
: The text to show the visitor.
36+
: Texto para ser mostrado ao visitante.
3737

3838
`default`
39-
: An optional second parameter, the initial value for the input field.
39+
: Um parâmetro opcional, valor inicial para o campo de entrada
40+
4041

41-
The visitor may type something in the prompt input field and press OK. Or they can cancel the input by pressing CANCEL or hitting the `key:Esc` key.
42+
O visitante pode digitar algo no campo de entrada do prompt e pressionar OK. Ou ele pode cancelar a entrada pressionando CANCEL ou `key:Esc`.
4243

43-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
44+
A chamada do `prompt` retorna o texto do campo de entrada ou `null` se a entrada foi cancelada.
4445

45-
For instance:
46+
Por exemplo:
4647

4748
```js run
48-
let age = prompt('How old are you?', 100);
49+
let age = prompt('Qual a sua idade ?', 100);
4950

50-
alert(`You are ${age} years old!`); // You are 100 years old!
51+
alert(`Você tem ${age} anos!`); //Você tem 100 anos!
5152
```
5253

5354
````warn header="In IE: always supply a `default`"
54-
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
55+
O segundo parâmetro é opcional, mas se não o fornecermos, Internet Explorer irá inserir o texto `"undefined"` no prompt.
5556

56-
Run this code in Internet Explorer to see:
57+
Execute este código no Internet Explorer para visualizar:
5758

5859
```js run
59-
let test = prompt("Test");
60+
let test = prompt("Teste");
6061
```
6162

62-
So, for prompts to look good in IE, we recommend always providing the second argument:
63+
portanto, para que os prompts tenham boa aparência no IE, recomendamos sempre fornecer o segundo argumento:
6364

6465
```js run
65-
let test = prompt("Test", ''); // <-- for IE
66+
let test = prompt("Teste", ''); // <-- para IE
6667
```
6768
````
6869
6970
## confirm
7071
71-
The syntax:
72+
Sintaxe:
7273
7374
```js
7475
result = confirm(question);
7576
```
7677
77-
The function `confirm` shows a modal window with a `question` and two buttons: OK and CANCEL.
78-
79-
The result is `true` if OK is pressed and `false` otherwise.
80-
81-
For example:
78+
A função `confirm` mostra uma janela modal com uma `question` e dois botões: OK e CANCEL.
79+
O resultado é `true` se OK for pressionado e `false` caso contrário
80+
Por exemplo:
8281
8382
```js run
84-
let isBoss = confirm("Are you the boss?");
83+
let isBoss = confirm("Você é o chefe ?");
8584
86-
alert( isBoss ); // true if OK is pressed
85+
alert( isBoss ); // true se OK for pressionado
8786
```
8887
89-
## Summary
88+
## Sumário
9089
91-
We covered 3 browser-specific functions to interact with visitors:
90+
Cobrimos 3 funções específicas do navegador para interagir com o visitante:
9291
9392
`alert`
94-
: shows a message.
93+
: mostra uma mensagem.
9594
9695
`prompt`
97-
: shows a message asking the user to input text. It returns the text or, if CANCEL or `key:Esc` is clicked, `null`.
96+
: mostra uma mensagem pedindo para o usuário inserir texto. Ele retorna o texto ou, se CANCEL ou `key:Esc` for clicado, `null`.
9897
9998
`confirm`
100-
: shows a message and waits for the user to press "OK" or "CANCEL". It returns `true` for OK and `false` for CANCEL/`key:Esc`.
99+
: mostra uma mensagem e espera o usuário pressionar "OK" ou "CANCEL". Ele retorna `true` para OK e `false` para CANCEL/`key:Esc`.
101100
102-
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
101+
Todos esse métodos são modais: eles pausam a execução do script e não permitem o visitante interagir com o resto da página até que a janela seja descartada.
103102
104-
There are two limitations shared by all the methods above:
103+
Existem duas limitações compartilhada entre esses metódos acima:
105104
106-
1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
107-
2. The exact look of the window also depends on the browser. We can't modify it.
105+
1. A localização exata da janela modal é determinada pelo navegador. Geralmente, está no centro.
106+
2. A aparência exata da janela também depende do navegador. Nós não podemos modificá-la.
108107
109-
That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
108+
Esse é o preço da simplicidade. Existem outras duas maneiras de mostrar janelas mais agradáveis e interações mais ricas com os visitantes, mas se "sinos e assobios" não importam muito, esses métodos funcionam bem.

0 commit comments

Comments
 (0)