diff --git a/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html b/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html index 7228a45de..65d01ef89 100644 --- a/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html @@ -1,22 +1,20 @@ - + + + + - - - + + - +
Tekst
- - -
Text
- - - + + diff --git a/2-ui/2-events/01-introduction-browser-events/01-hide-other/source.view/index.html b/2-ui/2-events/01-introduction-browser-events/01-hide-other/source.view/index.html index 17c5be6d1..d01585b1d 100644 --- a/2-ui/2-events/01-introduction-browser-events/01-hide-other/source.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/01-hide-other/source.view/index.html @@ -1,19 +1,16 @@ - + + + + - - - + + - +
Tekst
- - -
Text
- - - - + + diff --git a/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md b/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md index 7cb0cb0c9..b41aa9516 100644 --- a/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md +++ b/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md @@ -2,10 +2,10 @@ importance: 5 --- -# Hide on click +# Skjul ved klik -Add JavaScript to the `button` to make `
` disappear when we click it. +Tilføj JavaScript til `button` for at gøre `
` usynlig når vi klikker på den. -The demo: +Demo: [iframe border=1 src="solution" height=80] diff --git a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md index cded5b622..b8fbb4242 100644 --- a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md @@ -1,5 +1,5 @@ -Can use `this` in the handler to reference "the element itself" here: +Du kan her bruge `this` i handleren til at referere til "elementet selv": ```html run height=50 - + ``` diff --git a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md index 9ee8f18e1..61fa90f54 100644 --- a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md +++ b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md @@ -2,11 +2,11 @@ importance: 5 --- -# Hide self +# Skjul dig selv -Create a button that hides itself on click. +Opret en knap, der skjuler sig selv ved klik. ```online -Like this: - +Som dette: + ``` diff --git a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md index d569f0e4d..e9b9bebb0 100644 --- a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md @@ -1,8 +1,8 @@ -The answer: `1` and `2`. +Svaret er `1` og `2`. -The first handler triggers, because it's not removed by `removeEventListener`. To remove the handler we need to pass exactly the function that was assigned. And in the code a new function is passed, that looks the same, but is still another function. +Den første handler afvikles, fordi den ikke er blevet fjernet af `removeEventListener`. For at fjerne handleren skal vi overføre præcis den funktion, der var tildelt. Og i koden bliver en ny funktion overført, som ser den samme ud, men er stadig en anden funktion. -To remove a function object, we need to store a reference to it, like this: +For at fjerne et funktionsobjekt, skal vi gemme en reference til det, sådan her: ```js function handler() { @@ -13,4 +13,4 @@ button.addEventListener("click", handler); button.removeEventListener("click", handler); ``` -The handler `button.onclick` works independently and in addition to `addEventListener`. +Handleren `button.onclick` virker uafhængigt og i tilføjelse til `addEventListener`. diff --git a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md index f8cd75d5a..d9ea489b9 100644 --- a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md +++ b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md @@ -2,11 +2,11 @@ importance: 5 --- -# Which handlers run? +# Hvilken handler vil blive afviklet? -There's a button in the variable. There are no handlers on it. +Der er et element i variablen (en knap). Der er ingen handlers på den. -Which handlers run on click after the following code? Which alerts show up? +Hvilke handlers afvikles ved klik efter følgende kode? Hvilke alerts vises? ```js no-beautify button.addEventListener("click", () => alert("1")); diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md index b04cb8231..f59799c45 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md @@ -1,11 +1,11 @@ -First we need to choose a method of positioning the ball. +Først skal vi vælge en metode til at positionere bolden. -We can't use `position:fixed` for it, because scrolling the page would move the ball from the field. +Vi kan ikke bruge `position:fixed` til det, fordi scrolling af siden ville flytte bolden fra plænen. -So we should use `position:absolute` and, to make the positioning really solid, make `field` itself positioned. +Så vi bør bruge `position:absolute` og, for at gøre positioneringen virkelig solid, give selve `field` en `position`. -Then the ball will be positioned relatively to the field: +På den måde vil bolden blive positioneret relativt til plænen: ```css #field { @@ -16,36 +16,36 @@ Then the ball will be positioned relatively to the field: #ball { position: absolute; - left: 0; /* relative to the closest positioned ancestor (field) */ + left: 0; /* relativt til den nærmeste positionerede forælder (field) */ top: 0; - transition: 1s all; /* CSS animation for left/top makes the ball fly */ + transition: 1s all; /* CSS animation for left/top får bolden til at bevæge sig */ } ``` -Next we need to assign the correct `ball.style.left/top`. They contain field-relative coordinates now. +Derefter skal vi tildele de korrekte `ball.style.left/top`. De indeholder nu koordinater relative til plænen. -Here's the picture: +Her er et billede: ![](move-ball-coords.svg) -We have `event.clientX/clientY` -- window-relative coordinates of the click. +Vi har `event.clientX/clientY` -- koordinater relativt til vinduet. -To get field-relative `left` coordinate of the click, we can substract the field left edge and the border width: +For at få et field-relativt `left` koordinat, kan vi trække fields venstre side og border tykkelse fra: ```js let left = event.clientX - fieldCoords.left - field.clientLeft; ``` -Normally, `ball.style.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge, not center, would be under the mouse cursor. +Normalt betyder `ball.style.left` den "venstre kant af et element" (bolden). Så hvis vi tildeler den `left`, så vil det være boldens venstre side og ikke center der vil være under musemarkøren. -We need to move the ball half-width left and half-height up to make it center. +Vi skal flytte den halve bredde af bolden til venstre og den halve højde op for at centrere den. -So the final `left` would be: +Så den endelige `left` vil være: ```js let left = event.clientX - fieldCoords.left - field.clientLeft - ball.offsetWidth/2; ``` -The vertical coordinate is calculated using the same logic. +Den samme logik bruges til at beregne den lodrette koordinat. -Please note that the ball width/height must be known at the time we access `ball.offsetWidth`. Should be specified in HTML or CSS. +Bemærk, at boldens bredde/højde skal være kendt på det tidspunkt, hvor vi tilgår `ball.offsetWidth`. Den skal angives i HTML eller CSS. diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html index 3ebe8739e..dea7d5d8a 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html @@ -1,75 +1,69 @@ - + - - - - - - - - - Click on a field to move the ball there. -
- - -
- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -
- - - - + + + + + Klik på plænen for at flytte bolden derhen. +
+ +
+ + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +
+ + + diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/source.view/index.html b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/source.view/index.html index 34f9c88ae..0e876d953 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/source.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/source.view/index.html @@ -16,8 +16,8 @@ - Click on a field to move the ball there. -
The ball should never leave the field. + Klik på plænen for at flytte bolden derhen. +
Bolden må ikke forlade plænen.
diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/task.md b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/task.md index d5269147a..a6264c6d8 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/task.md +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/task.md @@ -2,20 +2,20 @@ importance: 5 --- -# Move the ball across the field +# Flyt bolden hen over plænen -Move the ball across the field to a click. Like this: +Flyt bolden hen over plænen til det sted der klikkes. Som dette: [iframe src="solution" height="260" link] -Requirements: +Krav: -- The ball center should come exactly under the pointer on click (if possible without crossing the field edge). -- CSS-animation is welcome. -- The ball must not cross field boundaries. -- When the page is scrolled, nothing should break. +- Boldens center skal være det sted der klikkes (hvis muligt uden at lande uden for plænen). +- CSS-animationer er velkomne. +- Bolden må ikke lande uden for plænen. +- Når siden scrolles, skal det stadig virke. -Notes: +Note: -- The code should also work with different ball and field sizes, not be bound to any fixed values. -- Use properties `event.clientX/event.clientY` for click coordinates. +- Koden skal kunne virke ved forskellige bold- og plæne-størrelser og må ikke være bundet til faste værdier. +- Brug egenskaberne `event.clientX/event.clientY` for klik-koordinater. diff --git a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.md b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.md index 7554a2f09..6448559e8 100644 --- a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.md @@ -1,47 +1,47 @@ # HTML/CSS -First let's create HTML/CSS. +Lad os først oprette HTML/CSS. -A menu is a standalone graphical component on the page, so it's better to put it into a single DOM element. +En menu er at selvstændigt element på side, så det bør puttes i sit eget DOM-element. -A list of menu items can be laid out as a list `ul/li`. +En liste at menupunkter kan opstilles som en liste `ul/li`. Here's the example structure: ```html ``` -We use `` for the title, because `
` has an implicit `display:block` on it, and it will occupy 100% of the horizontal width. +Vi bruger `` til titlen fordi `
` har en implicit `display:block` på det, og det vil optage 100% af den horisontale bredde. -Like this: +Sådan her: ```html autorun height=50 -
Sweeties (click me)!
+
Søde sager (klik her)!
``` -So if we set `onclick` on it, then it will catch clicks to the right of the text. +Så hvis vi sætter et `onclick` på det, så vil det også opfange klik til højre for teksten. -As `` has an implicit `display: inline`, it occupies exactly enough place to fit all the text: +Da `` har en implicit `display: inline`, optager det kun den plads, der er nødvendig for at rumme hele teksten: ```html autorun height=50 -Sweeties (click me)! +Søde sager (klik her)! ``` -# Toggling the menu +# Toggling af menu -Toggling the menu should change the arrow and show/hide the menu list. +Toggling af menu bør ændre pilen og vise/skjule menu-listen. -All these changes are perfectly handled by CSS. In JavaScript we should label the current state of the menu by adding/removing the class `.open`. +Alle disse ændringer håndteres perfekt af CSS. I JavaScript skal vi justere den tilstand menuen er i ved at tilføje eller fjerne klassen `.open`. -Without it, the menu will be closed: +Uden den vil menuen være uden den vil menuen være lukket: ```css .menu ul { @@ -58,7 +58,7 @@ Without it, the menu will be closed: } ``` -...And with `.open` the arrow changes and the list shows up: +... og med `.open` vil pilen ændres og listen vises: ```css .menu.open .title::before { diff --git a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.view/index.html b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.view/index.html index 0c1996a7e..49835e622 100644 --- a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/solution.view/index.html @@ -1,57 +1,53 @@ - + - - - - - - - - - - - - - + + + + + + + + + + diff --git a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/source.view/index.html b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/source.view/index.html index 03dded0cd..388877970 100644 --- a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/source.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/source.view/index.html @@ -1,16 +1,14 @@ - + - - - - - - ▶ ▼ Sweeties (click me)! -
    -
  • Cake
  • -
  • Donut
  • -
  • Honey
  • -
- - + + + + + ▶ ▼ Søde sager (klik her)! +
    +
  • Kage
  • +
  • Donut
  • +
  • Honning
  • +
+ diff --git a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/task.md b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/task.md index 34c313710..15a29eda6 100644 --- a/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/task.md +++ b/2-ui/2-events/01-introduction-browser-events/05-sliding-menu/task.md @@ -2,10 +2,12 @@ importance: 5 --- -# Create a sliding menu +# Opret en sliding menu -Create a menu that opens/collapses on click: +Opret en menu, der åbner/skjuler ved klik: [iframe border=1 height=100 src="solution"] -P.S. HTML/CSS of the source document is to be modified. +PS. Du skal også ændre HTML/CSS i dokumentet for at løse opgaven. + + diff --git a/2-ui/2-events/01-introduction-browser-events/06-hide-message/solution.md b/2-ui/2-events/01-introduction-browser-events/06-hide-message/solution.md index 022a0d977..0b2ae110c 100644 --- a/2-ui/2-events/01-introduction-browser-events/06-hide-message/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/06-hide-message/solution.md @@ -1,12 +1,12 @@ -To add the button we can use either `position:absolute` (and make the pane `position:relative`) or `float:right`. The `float:right` has the benefit that the button never overlaps the text, but `position:absolute` gives more freedom. So the choice is yours. +For at tilføje knappen kan vi enten bruge `position:absolute` (og gøre panelet `position:relative`) eller `float:right`. Fordelen ved `float:right` er at knappen aldrig overlapper teksten, men `position:absolute` giver mere frihed. Så valget er dit. -Then for each pane the code can be like: +Koden for hvert panel kan se således ud: ```js pane.insertAdjacentHTML("afterbegin", ''); ``` -Then the ` - - - The button code (may need to adjust CSS): - - -
-
-

Horse

-

The horse is one of two extant subspecies of Equus ferus. It is an odd-toed ungulate mammal belonging to the taxonomic family Equidae. The horse has evolved over the past 45 to 55 million years from a small multi-toed creature, Eohippus, into the large, single-toed animal of today.

-
-
-

Donkey

-

The donkey or ass (Equus africanus asinus) is a domesticated member of the horse family, Equidae. The wild ancestor of the donkey is the African wild ass, E. africanus. The donkey has been used as a working animal for at least 5000 years.

+
+
+

Hest

+

Hesten er en af to nulevende underarter af Equus ferus. Det er et oddetået hovdyr, der tilhører den taksonomiske familie af hestefamilien. Hesten har udviklet sig i løbet af de sidste 45 til 55 millioner år fra et lille væsen med mange tåer, Eohippus, til det store, entåede dyr, vi har i dag.

+
+
+

Æsel

+

Æslet eller æslet (Equus africanus asinus) er et domesticeret medlem af hestefamilien, Equidae. Æslets vilde forfader er det afrikanske vildæsel, E. africanus. Æslet har været brugt som arbejdsdyr i mindst 5000 år.

+
+
+

Kat

+

Huskatten (latin: Felis catus) er et lille, typisk loddent, kødædende pattedyr. De kaldes ofte huskatte, når de holdes som kæledyr, eller blot katte, når der ikke er behov for at skelne dem fra andre kattedyr. Katte værdsættes ofte af mennesker for deres selskab og for deres evne til at jage skadedyr.

+
-
-

Cat

-

The domestic cat (Latin: Felis catus) is a small, typically furry, carnivorous mammal. They are often called house cats when kept as indoor pets or simply cats when there is no need to distinguish them from other felids and felines. Cats are often valued by humans for companionship and for their ability to hunt vermin. -

-
-
- - + diff --git a/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md b/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md index 152cf41fe..d0e01def2 100644 --- a/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md +++ b/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md @@ -2,12 +2,12 @@ importance: 5 --- -# Add a closing button +# Tilføj en lukkeknap -There's a list of messages. +Der er en liste af beskeder. -Use JavaScript to add a closing button to the right-upper corner of each message. +Brug nu JavaScript til at tilføje en lukkeknap til højre i hjørnet af hver besked. -The result should look like this: +Resultatet skal se sådan ud: [iframe src="solution" height=450] diff --git a/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md b/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md index 1c6b52cea..6c2b95390 100644 --- a/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md @@ -1,17 +1,17 @@ -The images ribbon can be represented as `ul/li` list of images ``. +Billederne i båndet kan repræsenteres som en `ul/li` liste af billeder ``. -Normally, such a ribbon is wide, but we put a fixed-size `
` around to "cut" it, so that only a part of the ribbon is visible: +Normalt vil sådan et bånd være meget bredt, men vi putter en fast størrelse `
` omkring for at "beskære" det, så det kun er en del af båndet der er synligt: ![](carousel1.svg) -To make the list show horizontally we need to apply correct CSS properties for `
  • `, like `display: inline-block`. +For at vise listen vandret, kan vi anvende CSS-egenskaber for `
  • `, som f.eks. `display: inline-block`. -For `` we should also adjust `display`, because by default it's `inline`. There's extra space reserved under `inline` elements for "letter tails", so we can use `display:block` to remove it. +For `` bør vi også justere `display`, fordi standard er `inline`. Der er afsat ekstra plads under `inline`-elementer til "underliggere" (bogstaver der går under grundlinjen). Med `display:block` fjerner vi den plads. -To do the scrolling, we can shift `
      `. There are many ways to do it, for instance by changing `margin-left` or (better performance) use `transform: translateX()`: +Til at udføre scrolling, kan vi flytte `
        `. Der er mange måder at gøre det på. For eksempel kan vi ændre `margin-left` eller (endnu bedre ift ydeevne) bruge `transform: translateX()`: ![](carousel2.svg) -The outer `
        ` has a fixed width, so "extra" images are cut. +Den ydre `
        ` har en fast bredde, så "ekstra" billeder bliver beskåret. -The whole carousel is a self-contained "graphical component" on the page, so we'd better wrap it into a single `