|
206 | 206 | var thisObj, headingLevel, headingType, headingId, $chaptersHeading, |
207 | 207 | $chaptersNav, $chaptersList, $chapterItem, $chapterButton, |
208 | 208 | i, itemId, chapter, buttonId, hasDefault, |
209 | | - getFocusFunction, getHoverFunction, getBlurFunction, getClickFunction, |
210 | | - $thisButton, $thisListItem, $prevButton, $nextButton, blurListener; |
| 209 | + getClickFunction, $clickedItem, $chaptersList, thisChapterIndex; |
211 | 210 |
|
212 | 211 | thisObj = this; |
213 | 212 |
|
|
248 | 247 | // add event listeners |
249 | 248 | getClickFunction = function (time) { |
250 | 249 | return function () { |
251 | | - $(this).closest('ul').find('li') |
252 | | - .removeClass('able-current-chapter') |
253 | | - .attr('aria-selected',''); |
254 | | - $(this).closest('li') |
255 | | - .addClass('able-current-chapter') |
256 | | - .attr('aria-selected','true'); |
| 250 | + $clickedItem = $(this).closest('li'); |
| 251 | + $chaptersList = $(this).closest('ul').find('li'); |
| 252 | + thisChapterIndex = $chaptersList.index($clickedItem); |
| 253 | + $chaptersList.removeClass('able-current-chapter').attr('aria-selected',''); |
| 254 | + $clickedItem.addClass('able-current-chapter').attr('aria-selected','true'); |
| 255 | + thisObj.currentChapter = thisObj.chapters[thisChapterIndex]; |
257 | 256 | thisObj.seekTo(time); |
258 | 257 | } |
259 | 258 | }; |
|
329 | 328 |
|
330 | 329 | AblePlayer.prototype.injectAlert = function () { |
331 | 330 |
|
| 331 | + // inject two alerts, one visible for all users and one for screen reader users only |
| 332 | + |
332 | 333 | var top; |
333 | 334 |
|
334 | | - this.alertBox = $('<div role="alert"></div>'); |
335 | | - this.alertBox.addClass('able-alert'); |
336 | | - this.alertBox.appendTo(this.$ableDiv); |
| 335 | + this.$alertBox = $('<div role="alert"></div>'); |
| 336 | + this.$alertBox.addClass('able-alert'); |
| 337 | + this.$alertBox.appendTo(this.$ableDiv); |
337 | 338 | if (this.mediaType == 'audio') { |
338 | 339 | top = -10; |
339 | 340 | } |
340 | 341 | else { |
341 | 342 | top = Math.round(this.$mediaContainer.offset().top * 10) / 10; |
342 | 343 | } |
343 | | - this.alertBox.css({ |
| 344 | + this.$alertBox.css({ |
344 | 345 | top: top + 'px' |
345 | 346 | }); |
| 347 | + |
| 348 | + this.$srAlertBox = $('<div role="alert"></div>'); |
| 349 | + this.$srAlertBox.addClass('able-screenreader-alert'); |
| 350 | + this.$srAlertBox.appendTo(this.$ableDiv); |
346 | 351 | }; |
347 | 352 |
|
348 | 353 | AblePlayer.prototype.injectPlaylist = function () { |
|
0 commit comments