Commit cf69e35f by jmclaus

Adressed pull request comments

parent b2ff98f0
...@@ -62,8 +62,7 @@ function () { ...@@ -62,8 +62,7 @@ function () {
state.videoCaption.bindHandlers = _.bind(bindHandlers, state); state.videoCaption.bindHandlers = _.bind(bindHandlers, state);
state.videoCaption.fetchCaption = _.bind(fetchCaption, state); state.videoCaption.fetchCaption = _.bind(fetchCaption, state);
state.videoCaption.captionURL = _.bind(captionURL, state); state.videoCaption.captionURL = _.bind(captionURL, state);
state.videoCaption.captionMouseEnter = _.bind(captionMouseEnter, state); state.videoCaption.captionMouseEnterLeave = _.bind(captionMouseEnterLeave, state);
state.videoCaption.captionMouseLeave = _.bind(captionMouseLeave, state);
state.videoCaption.captionMouseDown = _.bind(captionMouseDown, state); state.videoCaption.captionMouseDown = _.bind(captionMouseDown, state);
state.videoCaption.captionMouseUp = _.bind(captionMouseUp, state); state.videoCaption.captionMouseUp = _.bind(captionMouseUp, state);
state.videoCaption.captionFocus = _.bind(captionFocus, state); state.videoCaption.captionFocus = _.bind(captionFocus, state);
...@@ -325,14 +324,17 @@ function () { ...@@ -325,14 +324,17 @@ function () {
this.videoCaption.subtitlesEl.html(container.html()); this.videoCaption.subtitlesEl.html(container.html());
this.videoCaption.subtitlesEl.find('li[data-index]').on('mouseenter', this.videoCaption.captionMouseEnter); this.videoCaption.subtitlesEl.find('li[data-index]').on({
this.videoCaption.subtitlesEl.find('li[data-index]').on('mouseleave', this.videoCaption.captionMouseLeave); mouseenter: this.videoCaption.captionMouseEnterLeave,
this.videoCaption.subtitlesEl.find('li[data-index]').on('mousedown', this.videoCaption.captionMouseDown); mouseleave: this.videoCaption.captionMouseEnterLeave,
this.videoCaption.subtitlesEl.find('li[data-index]').on('mouseup', this.videoCaption.captionMouseUp); mousedown: this.videoCaption.captionMouseDown,
this.videoCaption.subtitlesEl.find('li[data-index]').on('click', this.videoCaption.captionMouseUp); mouseup: this.videoCaption.captionMouseUp,
this.videoCaption.subtitlesEl.find('li[data-index]').on('focus', this.videoCaption.captionFocus); click: this.videoCaption.captionMouseUp,
this.videoCaption.subtitlesEl.find('li[data-index]').on('blur', this.videoCaption.captionBlur); focus: this.videoCaption.captionFocus,
this.videoCaption.subtitlesEl.find('li[data-index]').on('keydown', this.videoCaption.captionKeyDown); blur: this.videoCaption.captionBlur,
keydown: this.videoCaption.captionKeyDown
});
this.videoCaption.automaticScroll = true; this.videoCaption.automaticScroll = true;
this.videoCaption.currentCaptionIndex = 0; this.videoCaption.currentCaptionIndex = 0;
this.videoCaption.isMouseFocus = false; this.videoCaption.isMouseFocus = false;
...@@ -344,20 +346,13 @@ function () { ...@@ -344,20 +346,13 @@ function () {
} }
// On mouseEnter, hide the outline of a caption that has been tabbed to. // On mouseEnter, hide the outline of a caption that has been tabbed to.
function captionMouseEnter(event) {
var caption = $(event.target);
var captionIndex = parseInt(caption.attr('data-index'), 10);
if (captionIndex === this.videoCaption.currentCaptionIndex) {
caption.css('outlineWidth', '0px');
}
}
// On mouseLeave, show the outline of a caption that has been tabbed to. // On mouseLeave, show the outline of a caption that has been tabbed to.
function captionMouseLeave(event) { function captionMouseEnterLeave(event) {
var caption = $(event.target), var caption = $(event.target),
outlineWidth = (event.type === 'mouseleave') ? 1 : 0,
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
if (captionIndex === this.videoCaption.currentCaptionIndex) { if (captionIndex === this.videoCaption.currentCaptionIndex) {
caption.css('outlineWidth', '1px'); caption.css('outlineWidth', outlineWidth + 'px');
} }
} }
...@@ -379,21 +374,22 @@ function () { ...@@ -379,21 +374,22 @@ function () {
// automatic scrolling. // automatic scrolling.
if (this.videoCaption.isMouseFocus) { if (this.videoCaption.isMouseFocus) {
this.videoCaption.automaticScroll = true; this.videoCaption.automaticScroll = true;
caption.css('outlineWidth', '0px'); caption.css({
caption.css('outlineStyle', 'none'); 'outlineWidth': '0px',
'outlineStyle': 'none'
});
} }
// 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.videoCaption.currentCaptionIndex = captionIndex; this.videoCaption.currentCaptionIndex = captionIndex;
caption.css('outlineWidth', '1px'); caption.css({
caption.css('outlineStyle', 'dotted'); 'outlineWidth': '1px',
'outlineStyle': 'dotted'
});
// 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 (captionIndex === 0 || if (captionIndex <= 1 || captionIndex >= this.videoCaption.captions.length-2) {
captionIndex === 1 ||
captionIndex === this.videoCaption.captions.length-2 ||
captionIndex === this.videoCaption.captions.length-1) {
this.videoCaption.automaticScroll = false; this.videoCaption.automaticScroll = false;
} }
} }
...@@ -402,8 +398,10 @@ function () { ...@@ -402,8 +398,10 @@ function () {
function captionBlur(event) { function captionBlur(event) {
var caption = $(event.target), var caption = $(event.target),
captionIndex = parseInt(caption.attr('data-index'), 10); captionIndex = parseInt(caption.attr('data-index'), 10);
caption.css('outlineWidth', '0px'); caption.css({
caption.css('outlineStyle', 'none'); 'outlineWidth': '0px',
'outlineStyle': 'none'
});
// If we are on first or last index, we have to turn automatic scroll on // 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 direction we // 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 tabbing back out // are tabbing. So we could be on the first element and tabbing back out
......
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