Commit 439ca1dd by kimth

Write setter, toggle uses setter

parent 1625125e
......@@ -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()
......
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
......
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