- Notifications
You must be signed in to change notification settings - Fork230
Event delegation#353
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
Uh oh!
There was an error while loading.Please reload this page.
Event delegation#353
Changes fromall commits
234b419e06394e5dc484eff39c36475c3e75e4510884c78f0b23c55e9517ef97e24604f1cf397031c98ac21381048483634c69af141c7660789814d2ec19791f09fd137fc3f369391c00d26d8ee92bf9082ef753204f06a91d4874File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| La solución tiene dos partes. | ||
| 1.Envuelve cada nodo de título del árbol dentro de`<span>`.Luego podemos aplicarles CSS-styleen`: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). | ||
vplentinax marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 2.Establece el manejador al nodo raíz del`tree`y maneja los clics en aquellos títulos`<span>`. | ||
vplentinax marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -2,13 +2,13 @@ importance: 5 | ||||||
| --- | ||||||
| #Menú de árbol | ||||||
| Crea un árbol que muestre y oculte nodos hijos con clics: | ||||||
vplentinax marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||
| [iframe border=1 src="solution"] | ||||||
| Requerimientos: | ||||||
| -Solamente un manejador de eventos (usa delegación) | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Lo mismo que mi comentario anterior. Parece que a elección de@joaquinelio prefiere "manejador" | ||||||
| -Un clic fuera de los nodos de títulos (en un espacio vacío) no debe hacer nada. | ||||||
vplentinax marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,11 +2,11 @@ importance: 4 | ||
| --- | ||
| #Tabla ordenable | ||
| Haz que la tabla se pueda ordenar: los clics en elementos`<th>`deberían ordenarla por la columna correspondiente. | ||
vplentinax marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Cada `<th>`tiene su tipo de datos en el atributo, como esto: | ||
| ```html | ||
| <table id="grid"> | ||
| @@ -32,12 +32,12 @@ Each `<th>` has the type in the attribute, like this: | ||
| </table> | ||
| ``` | ||
| 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. | ||
| Solamente los tipos`"string"`y `"number"`deben ser soportados. | ||
| Ejemplo en funcionamiento: | ||
| [iframe border=1 src="solution" height=190] | ||
| P.D. La tabla puede ser grande, con cualquier cantidad de filas y columnas. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -2,37 +2,37 @@ importance: 5 | ||||||
| --- | ||||||
| #Comportamiento: Tooltip | ||||||
| Crea código JS para el comportamiento "tooltip". | ||||||
joaquinelio marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||
| Cuando un mousepasa sobre un elemento con `data-tooltip`,el tooltipdebe aparecer sobre él, y ocultarse cuando se va. | ||||||
| Un ejemplo enHTML comentado: | ||||||
| ```html | ||||||
| <button data-tooltip="the tooltip is longer than the element">Short button</button> | ||||||
| <button data-tooltip="HTML<br>tooltip">One more button</button> | ||||||
| ``` | ||||||
| Debe funcionar así: | ||||||
| [iframe src="solution" height=200 border=1] | ||||||
| En esta tarea suponemos que todos los elementos con `data-tooltip`solo tienen texto dentro. Sintagsanidados (todavía). | ||||||
| Detalles: | ||||||
| -La distancia entre el elemento y el tooltipdebe ser `5px`. | ||||||
| -El tooltipdebe ser centrado relativo al elemento si es posible. | ||||||
| -El tooltipno 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 ynohay espacio para eltooltip,entonces debajo de él. | ||||||
| -El contenido deltooltipestá dado en el atributo `data-tooltip`. Este puede serHTML arbitrario. | ||||||
| Necesitarás dos eventos aquí: | ||||||
| - `mouseover`se dispara cuando el puntero pasa sobre el elemento. | ||||||
| - `mouseout`se dispara cuando el puntero deja el elemento. | ||||||
| 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 lostooltipsdesde allí. | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||||
| Después de implementar el comportamiento, incluso gente no familiarizada conJavaScriptpuede agregar elementos anotados. | ||||||
| P.D. Solamente un tooltippuede mostrarse a la vez. | ||||||
Uh oh!
There was an error while loading.Please reload this page.