Skip to content

Commit f0157e7

Browse files
authored
Merge pull request #205 from pierangelomiceli/eventdelegationstasks
Event delegation - task and solutions
2 parents 1694e8a + 1b632ec commit f0157e7

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

2-ui/2-events/03-event-delegation/1-hide-message-delegate/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ importance: 5
22

33
---
44

5-
# Hide messages with delegation
5+
# Nascondere messaggi traminte delegation
66

7-
There's a list of messages with removal buttons `[x]`. Make the buttons work.
7+
C'è una lista di messaggi con il pulsante di rimozione `[x]`. Fare in modo che il pulsante funzioni.
88

9-
Like this:
9+
Come questo per esempio:
1010

1111
[iframe src="solution" height=420]
1212

13-
P.S. Should be only one event listener on the container, use event delegation.
13+
P.S.: Sul container dovrebbe esserci solo un listener, usare event delegation.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution has two parts.
1+
La soluzione viene divisa in due parti distinte.
22

3-
1. Wrap every tree node title into `<span>`. Then we can CSS-style them on `:hover` and handle clicks exactly on text, because `<span>` width is exactly the text width (unlike without it).
4-
2. Set a handler to the `tree` root node and handle clicks on that `<span>` titles.
3+
1. Inglobare il nodo che rappresenta il titolo dentro uno `<span>` e su questo elemento modificare gli i CSS per l'`:hover`; la gestione dei click con lo `<span>` è agevole perché questo occupa esattamente la larghezza del testo.
4+
2. Impostare un gestore sul nodo radice dell'`albero` e gestire i click su questi titoli `<span>`.

2-ui/2-events/03-event-delegation/2-sliding-tree/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Tree menu
5+
# Menù ad albero
66

7-
Create a tree that shows/hides node children on click:
7+
Creare una struttura ad albero che al click, mostra o nasconde i nodi figli:
88

99
[iframe border=1 src="solution"]
1010

11-
Requirements:
11+
Requisiti:
1212

13-
- Only one event handler (use delegation)
14-
- A click outside the node title (on an empty space) should not do anything.
13+
- Un solo gestore di eventi (usare delegation)
14+
- Un click fuori dal nodo del titolo (su uno spazio vuoto) non dovrebbe generare alcuna operazione.

2-ui/2-events/03-event-delegation/3-sortable-table/task.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 4
22

33
---
44

5-
# Sortable table
5+
# Tabella ordinabile
66

7-
Make the table sortable: clicks on `<th>` elements should sort it by corresponding column.
7+
Rendere la tabella ordinabile: i click sui `<th>` dovrebbero ordinarne i valori secondo la colonna corrispondente.
88

9-
Each `<th>` has the type in the attribute, like this:
9+
Ogni `<th>` ha il suo tipo specificato nell'attributo, come in questo esempio:
1010

1111
```html
1212
<table id="grid">
@@ -32,12 +32,12 @@ Each `<th>` has the type in the attribute, like this:
3232
</table>
3333
```
3434

35-
In the example above the first column has numbers, and the second one -- strings. The sorting function should handle sort according to the type.
35+
Nell'esempio, la prima colonna contiene numeri, la seconda -- stringhe. La funzione di ordinamento dovrebbe gestire l'ordine secondo il tipo specificato in attributo.
3636

37-
Only `"string"` and `"number"` types should be supported.
37+
Devono essere supportati solo i tipi `"string"` e `"number"`.
3838

39-
The working example:
39+
Esempio funzionante:
4040

4141
[iframe border=1 src="solution" height=190]
4242

43-
P.S. The table can be big, with any number of rows and columns.
43+
P.S.: La tabella potrebbe essere grande, con una quantità arbitraria di righe e colonne.

2-ui/2-events/03-event-delegation/4-behavior-tooltip/task.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Tooltip behavior
5+
# Comportamento tooltip
66

7-
Create JS-code for the tooltip behavior.
7+
Creare uno script JS per un tooltip.
88

9-
When a mouse comes over an element with `data-tooltip`, the tooltip should appear over it, and when it's gone then hide.
9+
Quando il mouse passa sopra un elemento HTML con `data-tooltip`, dovrebbe comparire su di esso un tooltip, e scomparire dopo che ha abbandonato la usa area.
1010

11-
An example of annotated HTML:
11+
Un esempio di HTML con tooltip:
1212
```html
1313
<button data-tooltip="the tooltip is longer than the element">Short button</button>
1414
<button data-tooltip="HTML<br>tooltip">One more button</button>
@@ -18,21 +18,21 @@ Should work like this:
1818

1919
[iframe src="solution" height=200 border=1]
2020

21-
In this task we assume that all elements with `data-tooltip` have only text inside. No nested tags (yet).
21+
In questo compito assumiamo che tutti gli elementi con il `data-tooltip` contengano solamente testo. Nessun tag annidato.
2222

23-
Details:
23+
Dettagli:
2424

25-
- The distance between the element and the tooltip should be `5px`.
26-
- The tooltip should be centered relative to the element, if possible.
27-
- The tooltip should not cross window edges. Normally it should be above the element, but if the element is at the page top and there's no space for the tooltip, then below it.
28-
- The tooltip content is given in the `data-tooltip` attribute. It can be arbitrary HTML.
25+
- La distanza tra l'elemento e la sua tooltip dovrebbe essere di `5px`.
26+
- Il tooltip, possibilmente, dovrebbe essere centrato rispetto all'elemento.
27+
- Il tooltip non dovrebbe oltrepassare i bordi della finestra. Normalmente dovrebbe stare sopra l'elemento, ma se quest'ultimo dovesse essere nella parte superiore della finestra, allora dovrebbe stare sotto.
28+
- Il contenuto del tooltip è dato dall'attributo `data-tooltip`. Può essere un qualunque HTML.
2929

30-
You'll need two events here:
31-
- `mouseover` triggers when a pointer comes over an element.
32-
- `mouseout` triggers when a pointer leaves an element.
30+
Sono necessari due eventi:
31+
- `mouseover` viene innescato quando il puntatore passa sopra l'elemento.
32+
- `mouseout` innescato quando il puntatore abbandona un elemento.
3333

34-
Please use event delegation: set up two handlers on `document` to track all "overs" and "outs" from elements with `data-tooltip` and manage tooltips from there.
34+
Usare la event delegation: impostare due gestori su `document` per tenere traccia di tutti gli "overs" ed "outs" degli elementi con `data-tooltip` e gestirli da lì.
3535

36-
After the behavior is implemented, even people unfamiliar with JavaScript can add annotated elements.
36+
Dopo che il comportamento è stato implementato, anche persone non avvezze a JavaScript possono aggiungere elementi con i tooltip.
3737

38-
P.S. Only one tooltip may show up at a time.
38+
P.S.: Può essere mostrato solo un tooltip alla volta.

0 commit comments

Comments
 (0)