Commit 210da2c4 by kimth

Start to remember caption state

parent 2e34c4ae
...@@ -9,6 +9,12 @@ class @Video ...@@ -9,6 +9,12 @@ class @Video
@parseVideos @el.data('streams') @parseVideos @el.data('streams')
@fetchMetadata() @fetchMetadata()
@parseSpeed() @parseSpeed()
if $.cookie('hide_captions') == 'true'
@el.addClass('closed')
else
@el.removeClass('closed')
$("#video_#{@id}").data('video', this).addClass('video-load-complete') $("#video_#{@id}").data('video', this).addClass('video-load-complete')
if YT.Player if YT.Player
......
class @VideoCaption extends Subview class @VideoCaption extends Subview
initialize: -> initialize: ->
@loaded = false @loaded = false
bind: -> bind: ->
$(window).bind('resize', @resize) $(window).bind('resize', @resize)
...@@ -49,7 +49,7 @@ class @VideoCaption extends Subview ...@@ -49,7 +49,7 @@ class @VideoCaption extends Subview
@$('.subtitles').html(container.html()) @$('.subtitles').html(container.html())
@$('.subtitles li[data-index]').click @seekPlayer @$('.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())) @$('.subtitles').prepend($('<li class="spacing">').height(@topSpacingHeight()))
.append($('<li class="spacing">').height(@bottomSpacingHeight())) .append($('<li class="spacing">').height(@bottomSpacingHeight()))
...@@ -131,10 +131,12 @@ class @VideoCaption extends Subview ...@@ -131,10 +131,12 @@ class @VideoCaption extends Subview
toggle: (event) => toggle: (event) =>
event.preventDefault() event.preventDefault()
if @el.hasClass('closed') if @el.hasClass('closed')
$.cookie('hide_captions', 'false', expires: 3650, path: '/')
@$('.hide-subtitles').attr('title', 'Turn off captions') @$('.hide-subtitles').attr('title', 'Turn off captions')
@el.removeClass('closed') @el.removeClass('closed')
@scrollCaption() @scrollCaption()
else else
$.cookie('hide_captions', 'true', expires: 3650, path: '/')
@$('.hide-subtitles').attr('title', 'Turn on captions') @$('.hide-subtitles').attr('title', 'Turn on captions')
@el.addClass('closed') @el.addClass('closed')
......
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