Commit 0e1a56d9 by arjun810

Merge pull request #699 from MITx/kimth/remember-caption

Kimth/remember caption
parents b681e2bd 68e07011
......@@ -11,6 +11,8 @@ class @Video
@parseSpeed()
$("#video_#{@id}").data('video', this).addClass('video-load-complete')
@hide_captions = $.cookie('hide_captions') == 'true'
if YT.Player
@embed()
else
......
class @VideoCaption extends Subview
initialize: ->
@loaded = false
@loaded = false
bind: ->
$(window).bind('resize', @resize)
......@@ -49,7 +49,7 @@ class @VideoCaption extends Subview
@$('.subtitles').html(container.html())
@$('.subtitles li[data-index]').click @seekPlayer
# prepend and append an empty <li> for cosmatic reason
# prepend and append an empty <li> for cosmetic reason
@$('.subtitles').prepend($('<li class="spacing">').height(@topSpacingHeight()))
.append($('<li class="spacing">').height(@bottomSpacingHeight()))
......@@ -130,14 +130,21 @@ class @VideoCaption extends Subview
toggle: (event) =>
event.preventDefault()
if @el.hasClass('closed')
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
@$('.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()
......
......@@ -45,6 +45,7 @@ class @VideoPlayer extends Subview
events:
onReady: @onReady
onStateChange: @onStateChange
@caption.hideCaptions(@['video'].hide_captions)
addToolTip: ->
@$('.add-fullscreen, .hide-subtitles').qtip
......
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