diff --git a/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md b/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md index 4d175ca01..a9d53e210 100644 --- a/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md +++ b/2-ui/2-events/04-default-browser-action/1-why-return-false-fails/solution.md @@ -1,16 +1,16 @@ -When the browser reads the `on*` attribute like `onclick`, it creates the handler from its content. +Lorsque le navigateur lit l'attribut `on*`, comme `onclick`, il créer le gestionnaire depuis son contenu. -For `onclick="handler()"` the function will be: +Pour `onclick="handler()"` la fonction sera: ```js function(event) { - handler() // the content of onclick + handler() // le contenu de onclick } ``` -Now we can see that the value returned by `handler()` is not used and does not affect the result. +Maintenant nous pouvons voir que la valeur retournée par `handler()` n'est pas utilisée et n'affecte pas le résultat. -The fix is simple: +La correction est simple: ```html run -the browser will go to w3.org +le navigateur va aller sur w3.org ``` -The browser follows the URL on click, but we don't want it. +Le navigateur suit le lien lors du clic, mais nous ne voulons pas ça. -How to fix? +Comment réparer ce problème? diff --git a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md index 25079cb8d..fa4df83c4 100644 --- a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md +++ b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.md @@ -1,5 +1,5 @@ -That's a great use of the event delegation pattern. +C'est une bonne utilisation de la délégation d'évènement. -In real life instead of asking we can send a "logging" request to the server that saves the information about where the visitor left. Or we can load the content and show it right in the page (if allowable). +Dans la vie réelle au lieu de demander nous pouvons envoyer une requête de "logging" au serveur pour sauvegarder les informations sur où l'utilisateur a quitté. Ou nous pouvons charger le contenu et l'afficher directement dans la page (si permis). -All we need is to catch the `contents.onclick` and use `confirm` to ask the user. A good idea would be to use `link.getAttribute('href')` instead of `link.href` for the URL. See the solution for details. +Tout ce que nous avons à faire est de capturer le `contents.onclick` et utiliser `confirm` pour demander à l'utilisateur. Une bonne idée serait d'utiliser `link.getAttribute('href')` plutôt que `link.href` pour l'URL. Regardez la solution pour plus de détails. diff --git a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html index 51ac0838b..c7411c96d 100644 --- a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html +++ b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/solution.view/index.html @@ -24,7 +24,7 @@ contents.onclick = function(event) { function handleLink(href) { - let isLeaving = confirm(`Leave for ${href}?`); + let isLeaving = confirm(`Quitter pour ${href}?`); if (!isLeaving) return false; } diff --git a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/task.md b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/task.md index 6ca456c2c..30d1c65b6 100644 --- a/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/task.md +++ b/2-ui/2-events/04-default-browser-action/2-catch-link-navigation/task.md @@ -2,15 +2,15 @@ importance: 5 --- -# Catch links in the element +# Capturer des liens dans l'élément -Make all links inside the element with `id="contents"` ask the user if they really want to leave. And if they don't then don't follow. +Faire en sorte que tous les liens dans l'élément avec `id="contents"` demande à l'utilisateur s'il veut vraiment partir. Et s'il ne veut pas ne suivez pas le lien. -Like this: +Commce ceci: [iframe height=100 border=1 src="solution"] -Details: +Détails: -- HTML inside the element may be loaded or regenerated dynamically at any time, so we can't find all links and put handlers on them. Use event delegation. -- The content may have nested tags. Inside links too, like `...`. +- Le HTML à l'intérieur de l'élément peut être chargé ou regénéré dynamiquement à n'importe quel moment, donc nous ne pouvons pas trouver tous les liens et mettre des gestionnaires dessus. Utilisez la délégation d'évènement. +- Le contenu peut avoir des éléments imbriqués. À l'intérieur des liens aussi, comme ceci `...`. diff --git a/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.md b/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.md index 5ff60b5c0..873af0895 100644 --- a/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.md +++ b/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.md @@ -1 +1 @@ -The solution is to assign the handler to the container and track clicks. If a click is on the `` link, then change `src` of `#largeImg` to the `href` of the thumbnail. +La solution est d'assigner le gestionnaire au conteneur et suivre les clics. Si un clic est sur le lien ``, alors changer `src` de `#largeImg` pour le `href` de la miniature. diff --git a/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.view/index.html b/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.view/index.html index 524bc7152..f6bc63dd3 100644 --- a/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.view/index.html +++ b/2-ui/2-events/04-default-browser-action/3-image-gallery/solution.view/index.html @@ -12,7 +12,7 @@

Large image