Skip to content

Commit 0f685c6

Browse files
authored
Merge pull request #353 from joaquinelio/deledeve
Event delegation
2 parents 0e2d021 + 91d4874 commit 0f685c6

File tree

6 files changed

+112
-112
lines changed

6 files changed

+112
-112
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+
# Ocultar mensajes con delegación
66

7-
There's a list of messages with removal buttons `[x]`. Make the buttons work.
7+
Hay una lista de mensajes con botones para borrarlos `[x]`. Haz que funcionen.
88

9-
Like this:
9+
Como esto:
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.D. Debe haber solamente un _event lintener_ en el contenedor, usa delegación de eventos.
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 solución tiene dos partes.
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. Envuelve cada nodo de título del árbol dentro de `<span>`. Luego podemos aplicarles CSS-style en `:hover` y manejar los clics exactamente sobre el texto, porque el ancho de `<span>` es exactamente el ancho del texto (no lo será si no lo tiene).
4+
2. Establece el manejador al nodo raíz del `tree` y maneja los clics en aquellos títulos `<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ú de árbol
66

7-
Create a tree that shows/hides node children on click:
7+
Crea un árbol que muestre y oculte nodos hijos con clics:
88

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

11-
Requirements:
11+
Requerimientos:
1212

13-
- Only one event handler (use delegation)
14-
- A click outside the node title (on an empty space) should not do anything.
13+
- Solamente un manejador de eventos (usa delegación)
14+
- Un clic fuera de los nodos de títulos (en un espacio vacío) no debe hacer nada.

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+
# Tabla ordenable
66

7-
Make the table sortable: clicks on `<th>` elements should sort it by corresponding column.
7+
Haz que la tabla se pueda ordenar: los clics en elementos `<th>` deberían ordenarla por la columna correspondiente.
88

9-
Each `<th>` has the type in the attribute, like this:
9+
Cada `<th>` tiene su tipo de datos en el atributo, como esto:
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+
En el ejemplo anterior la primera columna tiene números y la segunda cadenas. La función de ordenamiento debe manejar el orden de acuerdo al tipo de dato.
3636

37-
Only `"string"` and `"number"` types should be supported.
37+
Solamente los tipos `"string"` y `"number"` deben ser soportados.
3838

39-
The working example:
39+
Ejemplo en funcionamiento:
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.D. La tabla puede ser grande, con cualquier cantidad de filas y columnas.

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

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

33
---
44

5-
# Tooltip behavior
5+
# Comportamiento: Tooltip
66

7-
Create JS-code for the tooltip behavior.
7+
Crea código JS para el comportamiento "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+
Cuando un mouse pasa sobre un elemento con `data-tooltip`, el tooltip debe aparecer sobre él, y ocultarse cuando se va.
1010

11-
An example of annotated HTML:
11+
Un ejemplo en HTML comentado:
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>
1515
```
1616

17-
Should work like this:
17+
Debe funcionar así:
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+
En esta tarea suponemos que todos los elementos con `data-tooltip` solo tienen texto dentro. Sin tags anidados (todavía).
2222

23-
Details:
23+
Detalles:
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 distancia entre el elemento y el tooltip debe ser `5px`.
26+
- El tooltip debe ser centrado relativo al elemento si es posible.
27+
- El tooltip no debe cruzar los bordes de la ventana. Normalmente debería estar sobre el elemento, pero si el elemento está en la parte superior de la página y no hay espacio para el tooltip, entonces debajo de él.
28+
- El contenido del tooltip está dado en el atributo `data-tooltip`. Este puede ser HTML arbitrario.
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+
Necesitarás dos eventos aquí:
31+
- `mouseover` se dispara cuando el puntero pasa sobre el elemento.
32+
- `mouseout` se dispara cuando el puntero deja el 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+
Usa delegación de eventos: prepare dos manejadores en el `document` para rastrear todos los "overs" y "outs" de los elementos con `data-tooltip` y administra los tooltips desde allí.
3535

36-
After the behavior is implemented, even people unfamiliar with JavaScript can add annotated elements.
36+
Después de implementar el comportamiento, incluso gente no familiarizada con JavaScript puede agregar elementos anotados.
3737

38-
P.S. Only one tooltip may show up at a time.
38+
P.D. Solamente un tooltip puede mostrarse a la vez.

0 commit comments

Comments
 (0)