Commit 439ca1dd by kimth

Write setter, toggle uses setter

parent 1625125e
...@@ -130,15 +130,20 @@ class @VideoCaption extends Subview ...@@ -130,15 +130,20 @@ class @VideoCaption extends Subview
toggle: (event) => toggle: (event) =>
event.preventDefault() event.preventDefault()
if @el.hasClass('closed') if @el.hasClass('closed') # Captions are "closed" e.g. turned off
$.cookie('hide_captions', 'false', expires: 3650, path: '/') @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') @$('.hide-subtitles').attr('title', 'Turn off captions')
@el.removeClass('closed') @el.removeClass('closed')
@scrollCaption() @scrollCaption()
else $.cookie('hide_captions', hide_captions, expires: 3650, path: '/')
$.cookie('hide_captions', 'true', expires: 3650, path: '/')
@$('.hide-subtitles').attr('title', 'Turn on captions')
@el.addClass('closed')
captionHeight: -> captionHeight: ->
if @el.hasClass('fullscreen') if @el.hasClass('fullscreen')
......
class @VideoPlayer extends Subview class @VideoPlayer extends Subview
initialize: -> initialize: ->
console.log(@['video'].hide_captions)
# Define a missing constant of Youtube API # Define a missing constant of Youtube API
YT.PlayerState.UNSTARTED = -1 YT.PlayerState.UNSTARTED = -1
...@@ -46,6 +45,7 @@ class @VideoPlayer extends Subview ...@@ -46,6 +45,7 @@ class @VideoPlayer extends Subview
events: events:
onReady: @onReady onReady: @onReady
onStateChange: @onStateChange onStateChange: @onStateChange
@caption.hideCaptions(@['video'].hide_captions)
addToolTip: -> addToolTip: ->
@$('.add-fullscreen, .hide-subtitles').qtip @$('.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