Youtube and stats modules style improvements
[snf-cloudcms] / cloudcms / static / cloudcms / js / youtube.js
index 2cc8a33..a7ada4a 100644 (file)
@@ -6,14 +6,14 @@ function  YouTube(options) {
   this.videoEl = this.wrapper.find('.player-placeholder');
   this.currwidth = this.wrapper.width();
   this.currheight = parseInt(458* (this.currwidth/816));
+  this.close = $('#stop-youtube');
   var self = this;
   
   this.player =  new YT.Player(this.videoEl[0], {
     height: self.currheight,
     width: self.currwidth,
     playerVars: { 'modestbranding':1},
-    videoId: options.youtube_id,
-    suggestedQuality: 'hd1080',
+    videoId: options.youtube_id, 
     events: {
       'onStateChange': function(event) {
         if ( event.data == YT.PlayerState.ENDED ) {
@@ -39,12 +39,13 @@ YouTube.prototype.initEvents = function() {
       self.wrapper.animate({
         height: self.currheight
       },1000, function(){
+        self.close.css('visibility','visible');
         self.link.hide();
-  self.player.setPlaybackQuality('hd1080');
+        self.player.setPlaybackQuality('hd720');
         self.player.playVideo(); 
       })
   });
-  $('.stop-youtube').click(function(e){
+  this.close.click(function(e){
     e.preventDefault();
     self.endEvents();
   })
@@ -52,12 +53,12 @@ YouTube.prototype.initEvents = function() {
 
 YouTube.prototype.endEvents = function() {
   var self = this;
-
+  self.close.css('visibility','hidden');
   self.image.fadeIn({duration:1500,easing:'easeOutCirc'}); 
-    $(self.player.a).show().fadeIn({duration:1500,easing:'easeOutCirc'}); 
-    self.wrapper.animate({
-      height:'282'
-    },1000, function(){
-      self.link.show();
+  $(self.player.a).show().fadeIn({duration:1500,easing:'easeOutCirc'}); 
+  self.wrapper.animate({
+    height:'282'
+  },1000, function(){
+    self.link.show();
   })
 }