From 439ca1dd59fce07c46ec450d45b6e4f6ed6df7dd Mon Sep 17 00:00:00 2001 From: kimth Date: Sat, 15 Sep 2012 17:18:21 -0400 Subject: [PATCH] Write setter, toggle uses setter --- .../js/src/video/display/video_caption.coffee | 19 ++++++++++++------- .../js/src/video/display/video_player.coffee | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee index ae6b0c8ed1..b1e41afc3c 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee @@ -130,16 +130,21 @@ class @VideoCaption extends Subview toggle: (event) => event.preventDefault() - if @el.hasClass('closed') - $.cookie('hide_captions', 'false', expires: 3650, path: '/') + if @el.hasClass('closed') # Captions are "closed" e.g. turned off + @hideCaptions(false) + else # Captions are on + @hideCaptions(true) + + hideCaptions: (hide_captions) => + if hide_captions + @$('.hide-subtitles').attr('title', 'Turn on captions') + @el.addClass('closed') + else @$('.hide-subtitles').attr('title', 'Turn off captions') @el.removeClass('closed') @scrollCaption() - else - $.cookie('hide_captions', 'true', expires: 3650, path: '/') - @$('.hide-subtitles').attr('title', 'Turn on captions') - @el.addClass('closed') - + $.cookie('hide_captions', hide_captions, expires: 3650, path: '/') + captionHeight: -> if @el.hasClass('fullscreen') $(window).height() - @$('.video-controls').height() diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee index 79d27d2633..bb89def63d 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee @@ -1,6 +1,5 @@ class @VideoPlayer extends Subview initialize: -> - console.log(@['video'].hide_captions) # Define a missing constant of Youtube API YT.PlayerState.UNSTARTED = -1 @@ -46,6 +45,7 @@ class @VideoPlayer extends Subview events: onReady: @onReady onStateChange: @onStateChange + @caption.hideCaptions(@['video'].hide_captions) addToolTip: -> @$('.add-fullscreen, .hide-subtitles').qtip