File: D:/HostingSpaces/Velosophe/carparkcannonball.cc/wwwroot/source/scripts/modules/modules.video.js
/*------------------------------------------------------------------------*/
/* Rodesk video module
/*------------------------------------------------------------------------*/
var rodeskVideo = (function () {
var settings;
var defaults = {
videoPlay: '.js-video .c-video__play',
};
/**
* Setup the module
*
*/
var _videoType = function( event ) {
$videoId = $( this ).attr( 'data-id' );
$videoType = $( this ).attr( 'data-type' );
$videoWrapper = $( this ).parent();
if( $videoType === 'vimeo' ) {
jQuery.ajax({
url: 'https://vimeo.com/api/v2/video/' + $videoId + '.json',
dataType: 'jsonp',
type: 'GET',
success: function( response ) {
$videoWrapper.html( '<iframe src="https://player.vimeo.com/video/'+$videoId+'?autoplay=1" width="685" height="386" frameborder="0" webkitAllowFullScreen mozallowfullscreen autoPlay allowFullScreen></iframe>' );
$videoWrapper.fitVids();
}
});
} else if( $videoType === 'youtube' ) {
jQuery.ajax({
url: "https://www.googleapis.com/youtube/v3/videos?part=id,snippet&id=" + $videoId + "&key=AIzaSyAXBfQgG0HgqLQmJW97m0ru9AOUXaM5O0I",
dataType: "jsonp",
type: 'GET',
success: function( response ) {
$videoWrapper.html('<iframe src="https://www.youtube.com/embed/'+$videoId+'?autoplay=1" width="685" height="386" frameborder="0" allowfullscreen webkitAllowFullScreen mozallowfullscreen autoPlay allowFullScreen></iframe>');
$videoWrapper.parent().fitVids();
}
});
} else {
return false;
}
};
/**
* Bind reveal events
* Close the cookie bar on click of the close button
*
*/
var _bindEvents = function() {
$( settings.videoPlay ).on( 'click', _videoType );
};
/**
* Init module
*/
var _init = function( options ) {
// Setup settings.
options = options || {};
settings = $.extend({}, defaults, options);
_bindEvents();
};
// Return public functions
return {
init: _init // Init this function
};
})(jQuery); // Fully reference jQuery after this point.