+function isIpadIphone(){\r
+ var flag = false;\r
+ var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone");\r
+ var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");\r
+ if(isiPhone > -1) { flag = true; }\r
+ if(isiPad > -1) { flag = true; }\r
+ return flag;\r
+}\r
+\r
function setContainerMinHeight( applicableDiv){\r
\r
if ( $(applicableDiv).length > 0 ) {\r
function YouTube(options) {
this.options = options;
this.wrapper = options.wrapper;
- this.link = this.wrapper.find('a');
+ this.alink = this.wrapper.find('a');
this.image = this.wrapper.find('img');
this.videoEl = this.wrapper.find('.player-placeholder');
this.currwidth = this.wrapper.width();
this.currheight = parseInt(458* (this.currwidth/816));
this.wrapper.css('height',this.currheight)
}
-
}, this));
-
this.initEvents();
-
}
YouTube.prototype.initEvents = function() {
var self = this;
- this.link.click(function(e){
+ this.alink.click(function(e){
e.preventDefault();
self.image.fadeOut({duration:2500,easing:'easeOutCirc'});
- $(self.player.a).hide().fadeIn({duration:3500,easing:'easeOutCirc'});
self.wrapper.animate({
height: self.currheight
},1000, function(){
self.close.css('visibility','visible');
- self.link.hide();
- self.player.setPlaybackQuality('hd720');
- self.player.playVideo();
+ self.alink.hide();
+ if (!(isIpadIphone())) {
+ self.player.playVideo();
+ }
})
});
this.close.click(function(e){
e.preventDefault();
- self.player.stopVideo();
self.endEvents();
})
}
YouTube.prototype.endEvents = function() {
var self = this;
+ self.player.pauseVideo();
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.alink.show();
})
-}
+}
\ No newline at end of file
</div>
<script>
-
var video_settings = {
'wrapper': $(".video-thumb"),
'youtube_id': '{{ content.youtube_id}}',
var youtube = new YouTube(video_settings);
window.youtube = youtube;
}
-</script>
\ No newline at end of file
+
+ // This code loads the IFrame Player API code asynchronously.
+ var tag = document.createElement('script');
+ tag.src = "https://www.youtube.com/iframe_api";
+ var firstScriptTag = document.getElementsByTagName('script')[0];
+ firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
+</script>