- Notifications
You must be signed in to change notification settings - Fork7
Translated article about alert, prompt and confirm#73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 4 additions & 4 deletions1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,8 +2,8 @@ importance: 4 | ||
--- | ||
#Paprastas puslapis | ||
Sukurkite internetinį puslapį, kuris klausia vardo ir paskui jį parodo. | ||
[demo] |
78 changes: 39 additions & 39 deletions1-js/02-first-steps/09-alert-prompt-confirm/article.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,109 @@ | ||
#Interakcija: alert, prompt, confirm | ||
Šioje pamokų dalyje kalbėsime apie JavaScript kalbą "tokia kokia ji yra", be aplinkai būdingų pataisymų. | ||
Bet vis dar naudosime naršykles kaip mūsų pavyzdinę aplinką, tad turėtume žinoti bent kelias vartotojo sąsajos (ang.user-interface) savybes. Šiame skyriuje susipažinsime su šiomis naršyklės funkcijomis`alert`, `prompt`ir `confirm`. | ||
## alert | ||
Sintaksė: | ||
```js | ||
alert(message); | ||
``` | ||
Parodo žinutę ir sustabdo skriptą iki kol vartotojas paspaus "OK". | ||
Pavyzdžiui: | ||
```js run | ||
alert("Labas"); | ||
``` | ||
Miniatiūrinis langelis su žinute yra vadinamas *modaliniu langeliu* (ang.*modal window*). Žodis "modalinis" reiškia, kad lankytojas negali naudotis likusiu puslapiu, spausti kitų mygtukų ir t.t. kol nesusitvarkė su langeliu. Šiuo atveju--iki kol paspaus "OK". | ||
## prompt | ||
Funkcija`prompt`priima du argumentus: | ||
```js no-beautify | ||
result = prompt(title, [default]); | ||
``` | ||
Parodo modalinį langelį su paprasta tekstine žinute, įvesties laukeliu lankytojui ir mygtukus OK/Cancel. | ||
`title` | ||
:Tekstas, kurį reikės parodyti lankytojui. | ||
`default` | ||
:Nebūtinas antras parametras, pradinė vertė įvesties laukeliui. | ||
Lankytojas gali ką nors įvesti laukelyje ir paspaustiOK.Arba jie gali atšaukti paspausdamiCancelar klaviatūroje`key:Esc`mygtuką. | ||
Iššauktas`prompt`grąžina tekstą iš įvesties laukelio arba`null`, jeigu įvestis buvo atšaukta. | ||
Pavyzdžiui: | ||
```js run | ||
let age = prompt('Kiek jums metų?', 100); | ||
alert(`Jums yra ${age}metų!`); //Jums yra 100metų! | ||
``` | ||
````warn header="IE naršyklėje: visada nurodykite `default`" | ||
Antras parametras nėra būtinas, bet jeigu jo nepateiksite, Internet Explorerįtrauks`"undefined"`įprompt tekstą. | ||
Norėdami išbandyti, paleiskite šį kodąInternet Explorernaršyklėje: | ||
```js run | ||
let test = prompt("Testas"); | ||
``` | ||
Tad tam, kad prompt visada gerai atrodytųIE,mes rekomenduojame visada pateikti antrą argumentą: | ||
```js run | ||
let test = prompt("Testas", ''); // <--skirta IE | ||
``` | ||
```` | ||
## confirm | ||
Sintaksė: | ||
```js | ||
result = confirm(question); | ||
``` | ||
Funkcija`confirm`parodo modalinį langelį su`question`(klausimu) ir dviem mygtukais: OKir Cancel. | ||
Rezultatas būna`true`, jeigu paspaudžiamasOKir`false`kitu atveju. | ||
Pavyzdžiui: | ||
```js run | ||
let isBoss = confirm("Ar tu esi bosas?"); | ||
alert( isBoss ); // true, jeigu paspaudžiamas OK | ||
``` | ||
##Santrauka | ||
Mes aptarėme 3naršyklei būdingas funkcijas skirtas bendrauti su lankytojais: | ||
`alert` | ||
:parodo žinutę. | ||
`prompt` | ||
:parodo žinutę prašydamas vartotojo įvesti tekstą. Grąžina tekstą arba, jeigu paspaudžiamasCancelar`key:Esc`grąžinamas `null`. | ||
`confirm` | ||
:parodo žinutę ir laukia kol lankytojas paspaus"OK"arba "Cancel".Grąžina`true`kai OKir `false`kai Cancel/`key:Esc`. | ||
Visi šie veiksmai yra modaliniai: jie sustabdo skripto vykdymą ir neleidžia lankytojams naudotis likusiu puslapiu kol langelis nėra uždaromas. | ||
Visus anksčiau minėtus metodus sieja du apribojimai: | ||
1.Naršyklė nustato tikslią modalinio langelio vietą. Dažniausiai tai yra centras. | ||
2.Tiksli langelio išvaizda taip pat priklauso nuo naršyklės. Mes jo pakeisti negalime. | ||
Tokia yra paprastumo kaina. Yra daug kitų būdų parodyti gražesnius langelius ir naudoti puikesnį bendravimą su lankytojais, bet jeigu nėra labai svarbu įmantrumai esami metodai veikia kuo puikiausiai. |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.