Commit 1e686f47 by Ari Rizzitano

[video] fix AC-343

[captions] move role attr from li element to nested span (AC-343)

[video] fix failing tests for video captions (AC-343)

[video] couple more failing tests (AC-343)

[video] properly outline the focused caption (AC-343)
parent 443edadc
...@@ -74,18 +74,18 @@ ...@@ -74,18 +74,18 @@
width: 0px; width: 0px;
height: 0px; height: 0px;
} }
.downloads-heading { .downloads-heading {
margin: 1em 0 0 0; margin: 1em 0 0 0;
} }
.wrapper-downloads { .wrapper-downloads {
display: flex; display: flex;
.hd { .hd {
margin: 0; margin: 0;
} }
.wrapper-download-video, .wrapper-download-video,
.wrapper-download-transcripts, .wrapper-download-transcripts,
.wrapper-handouts, .wrapper-handouts,
...@@ -95,27 +95,27 @@ ...@@ -95,27 +95,27 @@
@include padding-right($baseline); @include padding-right($baseline);
vertical-align: top; vertical-align: top;
} }
.wrapper-download-video { .wrapper-download-video {
.video-sources { .video-sources {
margin: 0; margin: 0;
} }
} }
.wrapper-download-transcripts { .wrapper-download-transcripts {
.list-download-transcripts { .list-download-transcripts {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
.transcript-option { .transcript-option {
margin: 0; margin: 0;
} }
} }
} }
.branding { .branding {
@include padding-right(0); @include padding-right(0);
...@@ -681,9 +681,9 @@ ...@@ -681,9 +681,9 @@
} }
} }
} }
&.video-fullscreen { &.video-fullscreen {
.closed-captions { .closed-captions {
width: 60%; width: 60%;
} }
...@@ -705,7 +705,7 @@ ...@@ -705,7 +705,7 @@
.subtitles-menu { .subtitles-menu {
height: 100%; height: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0 3px;
list-style: none; list-style: none;
li { li {
...@@ -716,6 +716,10 @@ ...@@ -716,6 +716,10 @@
color: #0074b5; // AA compliant color: #0074b5; // AA compliant
line-height: lh(); line-height: lh();
span {
display: block;
}
&.current { &.current {
color: #333; color: #333;
font-weight: 700; font-weight: 700;
...@@ -734,10 +738,10 @@ ...@@ -734,10 +738,10 @@
&:empty { &:empty {
margin-bottom: 0; margin-bottom: 0;
} }
&.spacing:last-of-type { &.spacing:last-of-type {
position: relative; position: relative;
.transcript-end { .transcript-end {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
......
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
mousewheel: this.onMovement, mousewheel: this.onMovement,
DOMMouseScroll: this.onMovement DOMMouseScroll: this.onMovement
}) })
.on(events, 'li[data-index]', this.onCaptionHandler); .on(events, 'span[data-index]', this.onCaptionHandler);
this.container.on({ this.container.on({
mouseenter: this.onContainerMouseEnter, mouseenter: this.onContainerMouseEnter,
mouseleave: this.onContainerMouseLeave mouseleave: this.onContainerMouseLeave
...@@ -739,16 +739,16 @@ ...@@ -739,16 +739,16 @@
*/ */
buildCaptions: function(container, start, captions) { buildCaptions: function(container, start, captions) {
var process = function(text, index) { var process = function(text, index) {
var liEl = $('<li>', { var $spanEl = $('<span>', {
'role': 'link', 'role': 'link',
'data-index': index, 'data-index': index,
'data-start': start[index], 'data-start': start[index],
'tabindex': 0 'tabindex': 0
}); });
HtmlUtils.setHtml($(liEl), HtmlUtils.HTML(text.toString())); HtmlUtils.setHtml($($spanEl), HtmlUtils.HTML(text.toString()));
return liEl[0]; return $spanEl.wrap('<li>').parent()[0]; // safe-lint: disable=javascript-jquery-insertion
}; };
return AsyncProcess.array(captions, process).done(function(list) { return AsyncProcess.array(captions, process).done(function(list) {
...@@ -912,20 +912,21 @@ ...@@ -912,20 +912,21 @@
*/ */
captionFocus: function(event) { captionFocus: function(event) {
var caption = $(event.target), var caption = $(event.target),
container = caption.parent(),
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
// If the focus comes from a mouse click, hide the outline, turn on // If the focus comes from a mouse click, hide the outline, turn on
// automatic scrolling and set currentCaptionIndex to point outside of // automatic scrolling and set currentCaptionIndex to point outside of
// caption list (ie -1) to disable mouseenter, mouseleave behavior. // caption list (ie -1) to disable mouseenter, mouseleave behavior.
if (this.isMouseFocus) { if (this.isMouseFocus) {
this.autoScrolling = true; this.autoScrolling = true;
caption.removeClass('focused'); container.removeClass('focused');
this.currentCaptionIndex = -1; this.currentCaptionIndex = -1;
} }
// If the focus comes from tabbing, show the outline and turn off // If the focus comes from tabbing, show the outline and turn off
// automatic scrolling. // automatic scrolling.
else { else {
this.currentCaptionIndex = captionIndex; this.currentCaptionIndex = captionIndex;
caption.addClass('focused'); container.addClass('focused');
// The second and second to last elements turn automatic scrolling // The second and second to last elements turn automatic scrolling
// off again as it may have been enabled in captionBlur. // off again as it may have been enabled in captionBlur.
if ( if (
...@@ -945,9 +946,10 @@ ...@@ -945,9 +946,10 @@
*/ */
captionBlur: function(event) { captionBlur: function(event) {
var caption = $(event.target), var caption = $(event.target),
container = caption.parent(),
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
caption.removeClass('focused'); container.removeClass('focused');
// If we are on first or last index, we have to turn automatic scroll // If we are on first or last index, we have to turn automatic scroll
// on again when losing focus. There is no way to know in what // on again when losing focus. There is no way to know in what
// direction we are tabbing. So we could be on the first element and // direction we are tabbing. So we could be on the first element and
...@@ -1057,11 +1059,12 @@ ...@@ -1057,11 +1059,12 @@
} }
this.subtitlesEl this.subtitlesEl
.find("li[data-index='" + newIndex + "']") .find("span[data-index='" + newIndex + "']")
.parent()
.addClass('current'); .addClass('current');
this.currentIndex = newIndex; this.currentIndex = newIndex;
this.captionDisplayEl.text(this.subtitlesEl.find("li[data-index='" + newIndex + "']").text()); this.captionDisplayEl.text(this.subtitlesEl.find("span[data-index='" + newIndex + "']").text());
this.scrollCaption(); this.scrollCaption();
} }
} }
......
...@@ -32,8 +32,8 @@ CSS_CLASS_NAMES = { ...@@ -32,8 +32,8 @@ CSS_CLASS_NAMES = {
'captions_closed': '.video.closed', 'captions_closed': '.video.closed',
'captions_rendered': '.video.is-captions-rendered', 'captions_rendered': '.video.is-captions-rendered',
'captions': '.subtitles', 'captions': '.subtitles',
'captions_text': '.subtitles li', 'captions_text': '.subtitles li span',
'captions_text_getter': '.subtitles li[role="link"][data-index="1"]', 'captions_text_getter': '.subtitles li span[role="link"][data-index="1"]',
'closed_captions': '.closed-captions', 'closed_captions': '.closed-captions',
'error_message': '.video .video-player .video-error', 'error_message': '.video .video-player .video-error',
'video_container': '.video', 'video_container': '.video',
......
...@@ -277,7 +277,7 @@ class VideoComponentPage(VideoPage): ...@@ -277,7 +277,7 @@ class VideoComponentPage(VideoPage):
line_number (int): caption line number line_number (int): caption line number
""" """
caption_line_selector = ".subtitles li[data-index='{index}']".format(index=line_number - 1) caption_line_selector = ".subtitles li span[data-index='{index}']".format(index=line_number - 1)
self.q(css=caption_line_selector).results[0].send_keys(Keys.ENTER) self.q(css=caption_line_selector).results[0].send_keys(Keys.ENTER)
def is_caption_line_focused(self, line_number): def is_caption_line_focused(self, line_number):
...@@ -288,10 +288,9 @@ class VideoComponentPage(VideoPage): ...@@ -288,10 +288,9 @@ class VideoComponentPage(VideoPage):
line_number (int): caption line number line_number (int): caption line number
""" """
caption_line_selector = ".subtitles li[data-index='{index}']".format(index=line_number - 1) caption_line_selector = ".subtitles li span[data-index='{index}']".format(index=line_number - 1)
attributes = self.q(css=caption_line_selector).attrs('class') caption_container = self.q(css=caption_line_selector).results[0].find_element_by_xpath('..')
return 'focused' in caption_container.get_attribute('class').split()
return 'focused' in attributes
@property @property
def is_slider_range_visible(self): def is_slider_range_visible(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment