From 4af429de000db033eae7d9e4b2db5e6909431122 Mon Sep 17 00:00:00 2001 From: myles Date: Thu, 20 Oct 2016 17:39:40 +0800 Subject: [PATCH 1/2] Remove "show_closed_captions" in cookie --- .../xmodule/js/src/video/09_video_caption.js | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js index d5d895530a75..118fea0f16ae 100644 --- a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js +++ b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js @@ -34,13 +34,12 @@ '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.listenForDragDrop(); return $.Deferred().resolve().promise(); @@ -1146,31 +1145,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(); } }, @@ -1212,19 +1194,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; From 8c0a3660597800e70915e09e15a0f0883eb930f8 Mon Sep 17 00:00:00 2001 From: Myles Date: Tue, 25 Oct 2016 08:18:34 +0000 Subject: [PATCH 2/2] Add initial state for closed_caption; Edited test to match code changes --- .../xmodule/js/src/video/09_video_caption.js | 1 + .../tests/video/test_video_module.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js index 118fea0f16ae..04a4ab27f30d 100644 --- a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js +++ b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js @@ -40,6 +40,7 @@ this.state = state; this.state.videoCaption = this; this.renderElements(); + this.hideClosedCaptions(); this.listenForDragDrop(); return $.Deferred().resolve().promise(); diff --git a/common/test/acceptance/tests/video/test_video_module.py b/common/test/acceptance/tests/video/test_video_module.py index 05c88ae2878c..4bca2f692547 100644 --- a/common/test/acceptance/tests/video/test_video_module.py +++ b/common/test/acceptance/tests/video/test_video_module.py @@ -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): """