1 function YouTube(options) {
2 this.options = options;
3 this.wrapper = options.wrapper;
4 this.link = this.wrapper.find('a');
5 this.image = this.wrapper.find('img');
6 this.videoEl = this.wrapper.find('.player-placeholder');
7 this.currwidth = this.wrapper.width();
8 this.currheight = parseInt(458* (this.currwidth/816));
9 this.close = $('#stop-youtube');
12 this.player = new YT.Player(this.videoEl[0], {
13 height: self.currheight,
14 width: self.currwidth,
15 playerVars: { 'modestbranding':1},
16 videoId: options.youtube_id,
18 'onStateChange': function(event) {
19 if ( event.data == YT.PlayerState.ENDED ) {
25 console.log(this.player);
26 // this.player.setPlaybackQuality('hd1080');
33 YouTube.prototype.initEvents = function() {
35 this.link.click(function(e){
37 self.image.fadeOut({duration:2500,easing:'easeOutCirc'});
38 $(self.player.a).hide().fadeIn({duration:3500,easing:'easeOutCirc'});
39 self.wrapper.animate({
40 height: self.currheight
42 self.close.css('visibility','visible');
44 self.player.setPlaybackQuality('hd720');
45 self.player.playVideo();
48 this.close.click(function(e){
54 YouTube.prototype.endEvents = function() {
56 self.close.css('visibility','hidden');
57 self.image.fadeIn({duration:1500,easing:'easeOutCirc'});
58 $(self.player.a).show().fadeIn({duration:1500,easing:'easeOutCirc'});
59 self.wrapper.animate({