Skip to content

Instantly share code, notes, and snippets.

@drale2k
Created October 21, 2012 09:26
Show Gist options
  • Save drale2k/3926488 to your computer and use it in GitHub Desktop.
Save drale2k/3926488 to your computer and use it in GitHub Desktop.
class Etaxi.Views.Videoplayer extends Backbone.View
template: JST['base/videoplayer']
tagName: "div"
id: "overlay-wrapper"
className: "videoplayer"
options:
title: "Video"
src: null
events:
"tap .overlay" : "hide"
"play video" : "test"
test: ->
alert "playing!"
initialize: ->
Etaxi.log "Videoplayer: initialized"
render: ->
$(@el).html(@template(video: @options))
$("body").append(@el)
$z(@el).animate
opacity:1
350
"ease-out"
.find('video').animate
scale:1
350
"cubic-bezier(.32,.85,.35,1.2)"
->
window.spinner = new Spinner(
color:'#fff'
radius: 7
length: 6
width: 3
lines: 9
trail: 34
).spin($(".overlay")[0])
Etaxi.log "Videoplayer: rendered"
this
hide: ->
$z(@el).animate
opacity:0
350
"ease-in"
=>
# Move the element from screen before we remove it
# to prevent the video from flickering.
$(@el).css
"top":"10000px"
setTimeout =>
$(@el).remove()
Etaxi.log "Videoplayer: removed"
, 100
spinner.stop()
_.extend Etaxi.Views.Videoplayer,
show: (title, poster, src, options) ->
# Only one videoplayer instance at once.
if not $(".videoplayer").length
new Etaxi.Views.Videoplayer(_.extend
title: title
poster: poster
src: src
, options).render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment