Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions common/lib/xmodule/xmodule/js/src/video/09_video_caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
'handleKeypress', 'handleKeypressLink', 'openLanguageMenu', 'closeLanguageMenu',
'previousLanguageMenuItem', 'nextLanguageMenuItem', 'handleCaptionToggle',
'showClosedCaptions', 'hideClosedCaptions', 'toggleClosedCaptions',
'updateCaptioningCookie', 'handleCaptioningCookie', 'handleTranscriptToggle',
'handleTranscriptToggle',
'listenForDragDrop'
);
this.state = state;
this.state.videoCaption = this;
this.renderElements();
this.handleCaptioningCookie();
this.hideClosedCaptions();
this.listenForDragDrop();

return $.Deferred().resolve().promise();
Expand Down Expand Up @@ -1146,31 +1146,14 @@
}
},

handleCaptioningCookie: function() {
if ($.cookie('show_closed_captions') === 'true') {
this.state.showClosedCaptions = true;
this.showClosedCaptions();

// keep it going until turned off
$.cookie('show_closed_captions', 'true', {
expires: 3650,
path: '/'
});
} else {
this.hideClosedCaptions();
}
},

toggleClosedCaptions: function(event) {
event.preventDefault();

if (this.state.el.hasClass('has-captions')) {
this.state.showClosedCaptions = false;
this.updateCaptioningCookie(false);
this.hideClosedCaptions();
} else {
this.state.showClosedCaptions = true;
this.updateCaptioningCookie(true);
this.showClosedCaptions();
}
},
Expand Down Expand Up @@ -1212,19 +1195,6 @@
this.state.el.trigger('captions:hide');
},

updateCaptioningCookie: function(method) {
if (method) {
$.cookie('show_closed_captions', 'true', {
expires: 3650,
path: '/'
});
} else {
$.cookie('show_closed_captions', null, {
path: '/'
});
}
},

listenForDragDrop: function() {
var captions = document.querySelector('.closed-captions'),
draggable;
Expand Down
18 changes: 12 additions & 6 deletions common/test/acceptance/tests/video/test_video_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,24 @@ def test_cc_button(self):
self.assets.append('chinese_transcripts.srt')
self.navigate_to_video()

# Show captions and make sure they're visible and cookie is set
# Captions should not be visible by default
self.assertFalse(self.video.is_closed_captions_visible())

# Show captions and make sure they're visible and reset after page reload
self.video.show_closed_captions()
self.video.wait_for_closed_captions()
self.assertTrue(self.video.is_closed_captions_visible)
self.assertTrue(self.video.is_closed_captions_visible())
self.video.reload_page()
self.assertTrue(self.video.is_closed_captions_visible)
self.assertFalse(self.video.is_closed_captions_visible())

# Now show captions again
self.video.show_closed_captions()
self.video.wait_for_closed_captions()
self.assertTrue(self.video.is_closed_captions_visible())

# Hide captions and make sure they're hidden and cookie is unset
# Hide captions and make sure they're hidden
self.video.hide_closed_captions()
self.video.wait_for_closed_captions_to_be_hidden()
self.video.reload_page()
self.video.wait_for_closed_captions_to_be_hidden()

def test_transcript_button_transcripts_and_sub_fields_empty(self):
"""
Expand Down