@@ -108,7 +108,7 @@ handler.
108108----
109109
110110(((function,as value)))To be able to unregister a handler function, we
111- give it a name (like `once` in the previous example ) so that we
111+ give it a name (such as `once`) so that we
112112can pass it to both `addEventListener` and `removeEventListener`.
113113
114114== Event objects ==
@@ -250,7 +250,7 @@ they expect is broken.
250250
251251Depending on the browser, some events can't be intercepted. On
252252Chrome, for example, ((keyboard)) shortcuts to close the current tab
253- (Control -W or Command-W) cannot be handled by JavaScript.
253+ (Ctrl -W or Command-W) cannot be handled by JavaScript.
254254
255255== Key events ==
256256
@@ -312,7 +312,7 @@ interested in.
312312(((modifier key)))(((shift key)))(((control key)))(((alt key)))(((meta
313313key)))(((command key)))(((ctrlKey property)))(((shiftKey
314314property)))(((altKey property)))(((metaKey property)))Modifier keys
315- such as Shift, Control , Alt, and Meta (Command on Mac) generate key
315+ such as Shift, Ctrl , Alt, and Meta (Command on Mac) generate key
316316events just like normal keys. But when looking for key combinations,
317317you can also find out whether these keys are held down by looking
318318at the `shiftKey`, `ctrlKey`, `altKey`, and `metaKey` properties of
@@ -321,7 +321,7 @@ keyboard and mouse events.
321321[source,text/html]
322322[focus="yes"]
323323----
324- <p>Press Control -Space to continue.</p>
324+ <p>Press Ctrl -Space to continue.</p>
325325<script>
326326 addEventListener("keydown", function(event) {
327327 if (event.keyCode == 32 && event.ctrlKey)
@@ -470,6 +470,8 @@ on this bar makes it narrower or wider:
470470
471471ifdef::book_target[]
472472
473+ The resulting page looks like this:
474+
473475image::img/drag-bar.png[alt="A draggable bar",width="5.3cm"]
474476
475477endif::book_target[]
@@ -643,6 +645,9 @@ focus:
643645
644646ifdef::book_target[]
645647
648+ The following screenshot shows the help text for the age field being
649+ shown.
650+
646651image::img/help-field.png[alt="Providing help when a field is focused",width="4.4cm"]
647652
648653endif::book_target[]
@@ -676,7 +681,7 @@ might expect, done with the `preventDefault` method. Instead, it is
676681done by returning a string from the handler. The string will be used
677682in a dialog that asks the user if they want to stay on the page or
678683leave it. This mechanism ensures that a user is able to leave the
679- page, even if it running a ((malicious script)) that would prefer to
684+ page, even if it is running a ((malicious script)) that would prefer to
680685keep them there forever in order to force them to look at dodgy
681686weight loss ads.
682687
@@ -777,7 +782,7 @@ var bombTimer = setTimeout(function() {
777782 console.log("BOOM!");
778783}, 500);
779784
780- if (Math.random() < .5) { // 50% chance
785+ if (Math.random() < 0 .5) { // 50% chance
781786 console.log("Defused.");
782787 clearTimeout(bombTimer);
783788}
@@ -813,7 +818,7 @@ event)))(((blocking)))Some types of events have the potential to fire
813818rapidly, many times in a row (the `"mousemove"` and `"scroll"` events,
814819for example). When handling such events, you must be careful not to do
815820anything too time-consuming or your handler will take up so much time
816- that interaction with the document will start to feel slow and choppy.
821+ that interaction with the document starts to feel slow and choppy.
817822
818823(((setTimeout function)))If you do need to do something nontrivial in
819824such a handler, you can use `setTimeout` to make sure you are not
@@ -825,7 +830,7 @@ event)))In the first example, we want to do something when the user
825830has typed something, but we don't want to do it immediately for every
826831key event. When they are ((typing)) quickly, we just want to wait
827832until a pause occurs. Instead of immediately performing an action in
828- the event handler, we can set a timeout instead. We also clear the
833+ the event handler, we set a timeout instead. We also clear the
829834previous timeout (if any) so that when events occur close together
830835(closer than our timeout delay), the timeout from the previous event
831836will be canceled.
@@ -885,7 +890,7 @@ Event handlers make it possible to detect and react to events we have
885890no direct control over. The `addEventListener` method is used to
886891register such a handler.
887892
888- Each event has a name (`"keydown"`, `"focus"`, and so on) that identifies
893+ Each event has a type (`"keydown"`, `"focus"`, and so on) that identifies
889894it. Most events are called on a specific DOM elements and then
890895_propagate_ to that element's ancestors, allowing handlers associated
891896with those elements to handle them.
@@ -978,7 +983,7 @@ follow the mouse pointer as you moved it across the page.
978983want you to implement a mouse trail. Use absolutely positioned `<div>`
979984elements with a fixed size and background color (refer to the
980985link:14_event.html#mouse_drawing[code] in the “Mouse Clicks”
981- section for an example). Create 12 such elements, and when the
986+ section for an example). Create a bunch of such elements and, when the
982987mouse moves, display them in the wake of the mouse pointer, somehow.
983988
984989(((mousemove event)))There are various possible approaches here. You
@@ -1041,13 +1046,13 @@ to you.
10411046=== Tabs ===
10421047
10431048(((tabbed interface (exercise))))A tabbed interface is a common design
1044- pattern. It allows you to select an interface panel by selecting from
1049+ pattern. It allows you to select an interface panel by choosing from
10451050a number of tabs “sticking out” above an element.
10461051
10471052(((button (HTML tag))))(((display (CSS))))(((hidden element)))(((data
10481053attribute)))In this exercise you'll implement a simple tabbed
10491054interface. Write a function, `asTabs`, that takes a DOM node and
1050- creates a tabbed interface showing the children of that node. It
1055+ creates a tabbed interface showing the child elements of that node. It
10511056should insert a list of `<button>` elements at the top of the node,
10521057one for each child element, containing text retrieved from the
10531058`data-tabname` attribute of the child. All but one of the original
0 commit comments