Commit 5ccf717d by jmclaus

Moved css from js file to relevant scss file.

parent c541fb7b
...@@ -531,6 +531,16 @@ div.video { ...@@ -531,6 +531,16 @@ div.video {
font-weight: 700; font-weight: 700;
} }
&.unfocused {
outline-width: 0px;
outline-style: none;
}
&.focused {
outline-width: 1px;
outline-style: dotted;
}
&:hover { &:hover {
color: $blue; color: $blue;
} }
......
...@@ -362,17 +362,21 @@ function () { ...@@ -362,17 +362,21 @@ function () {
// 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 captionMouseEnterLeave(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', outlineWidth + 'px'); if (event.type === 'mouseenter') {
caption.removeClass('focused').addClass('unfocused');
}
else { // mouseleave
caption.removeClass('unfocused').addClass('focused');
}
} }
} }
function captionMouseDown(event) { function captionMouseDown(event) {
var caption = $(event.target); var caption = $(event.target);
this.videoCaption.isMouseFocus = true; this.videoCaption.isMouseFocus = true;
caption.css('outlineWidth', '0px'); caption.removeClass('focused').addClass('unfocused');
this.videoCaption.autoScrolling = true; this.videoCaption.autoScrolling = true;
} }
...@@ -383,23 +387,19 @@ function () { ...@@ -383,23 +387,19 @@ function () {
function captionFocus(event) { function captionFocus(event) {
var caption = $(event.target), var caption = $(event.target),
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 and turn on // If the focus comes from a mouse click, hide the outline, turn on
// automatic scrolling. // automatic scrolling and set currentCaptionIndex to point outside of
// caption list (ie -1) to disable mouseenter, mouseleave behavior.
if (this.videoCaption.isMouseFocus) { if (this.videoCaption.isMouseFocus) {
this.videoCaption.autoScrolling = true; this.videoCaption.autoScrolling = true;
caption.css({ caption.removeClass('focused').addClass('unfocused');
'outlineWidth': '0px', this.videoCaption.currentCaptionIndex = -1;
'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({ caption.removeClass('unfocused').addClass('focused');
'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 <= 1 || captionIndex >= this.videoCaption.captions.length-2) { if (captionIndex <= 1 || captionIndex >= this.videoCaption.captions.length-2) {
...@@ -411,10 +411,7 @@ function () { ...@@ -411,10 +411,7 @@ 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({ caption.removeClass('focused').addClass('unfocused');
'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