/*___________________________________________________________________________________________________________________________________________________ _ jquery.mb.components _ _ _ _ file: jquery.mb.vimeo_player.js _ _ last modified: 26/12/16 15.39 _ _ _ _ Open Lab s.r.l., Florence - Italy _ _ _ _ email: matteo@open-lab.com _ _ site: http://pupunzi.com _ _ http://open-lab.com _ _ blog: http://pupunzi.open-lab.com _ _ Q&A: http://jquery.pupunzi.com _ _ _ _ Licences: MIT, GPL _ _ http://www.opensource.org/licenses/mit-license.php _ _ http://www.gnu.org/licenses/gpl.html _ _ _ _ Copyright (c) 2001-2016. Matteo Bicocchi (Pupunzi); _ ___________________________________________________________________________________________________________________________________________________*/ var get_vimeo_videoID = function( url ) { var videoID; if( url.indexOf( "vimeo.com" ) > 0 ) { videoID = url.substr( url.lastIndexOf( "/" ) + 1, url.length ); } else { videoID = url.length > 15 ? null : url; } return videoID }; ( function( $ ) { jQuery.vimeo_player = { name: "jquery.mb.vimeo_player", author: "Matteo Bicocchi (pupunzi)", version: "1.0.6", build: "373", defaults: { containment: "body", ratio: "16/9", // "auto", "16/9", "4/3" videoURL: null, startAt: 0, stopAt: 0, autoPlay: true, vol: 50, // 1 to 100 addRaster: false, opacity: 1, mute: false, loop: true, showControls: true, show_vimeo_logo: true, stopMovieOnBlur: true, realfullscreen: true, mobileFallbackImage: null, gaTrack: true, optimizeDisplay: true, mask: false, align: "center,center", // top,bottom,left,right onReady: function( player ) {} }, /** * @fontface icons * */ controls: { play: "P", pause: "p", mute: "M", unmute: "A", fullscreen: "O", showSite: "R", logo: "V" }, buildPlayer: function( options ) { var isIframe = function() { var isIfr = false; try { if( self.location.href != top.location.href ) isIfr = true; } catch( e ) { isIfr = true; } return isIfr; }; var script = document.createElement( 'script' ); script.src = "https://player.vimeo.com/api/player.js"; script.onload = function() { jQuery( document ).trigger( "vimeo_api_loaded" ); }; document.head.appendChild( script ); return this.each( function() { var vimeo_player = this; var $vimeo_player = jQuery( vimeo_player ); vimeo_player.loop = 0; vimeo_player.opt = {}; vimeo_player.state = {}; vimeo_player.id = vimeo_player.id || "YTP_" + new Date().getTime(); $vimeo_player.addClass( "vimeo_player" ); var property = $vimeo_player.data( "property" ) && typeof $vimeo_player.data( "property" ) == "string" ? eval( '(' + $vimeo_player.data( "property" ) + ')' ) : $vimeo_player.data( "property" ); jQuery.extend( vimeo_player.opt, jQuery.vimeo_player.defaults, options, property ); vimeo_player.opt.ratio = vimeo_player.opt.ratio == "auto" ? "16/9" : vimeo_player.opt.ratio; if( eval( vimeo_player.opt.loop ) ) vimeo_player.opt.loop = 9999; vimeo_player.isRetina = ( window.retina || window.devicePixelRatio > 1 ); vimeo_player.canGoFullScreen = !( jQuery.browser.msie || jQuery.browser.opera || isIframe() ); if( !vimeo_player.canGoFullScreen ) vimeo_player.opt.realfullscreen = false; vimeo_player.isAlone = false; vimeo_player.hasFocus = true; vimeo_player.videoID = this.opt.videoURL ? get_vimeo_videoID( this.opt.videoURL ) : $vimeo_player.attr( "href" ) ? get_vimeo_videoID( $vimeo_player.attr( "href" ) ) : false; vimeo_player.isSelf = vimeo_player.opt.containment == "self"; vimeo_player.opt.containment = vimeo_player.opt.containment == "self" ? jQuery( this ) : jQuery( vimeo_player.opt.containment ); vimeo_player.isBackground = vimeo_player.opt.containment.is( "body" ); if( vimeo_player.isBackground && vimeo_player.backgroundIsInited ) return; vimeo_player.canPlayOnMobile = vimeo_player.isSelf && jQuery( this ).children().length === 0; if( !vimeo_player.isSelf ) { $vimeo_player.hide(); } var overlay = jQuery( "
" ).css( { position: "absolute", top: 0, left: 0, width: "100%", height: "100%" } ).addClass( "vimeo_player_overlay" ); if( vimeo_player.isSelf ) { // overlay.on( "click", function() { // $vimeo_player.togglePlay(); // } ) } var playerID = "vimeo_player_" + vimeo_player.id; var wrapper = jQuery( "
" ).addClass( "vimeo_player_wrapper" ).attr( "id", "vimeo_player_wrapper_" + playerID ); wrapper.css( { position: "absolute", zIndex: 0, minWidth: "100%", minHeight: "100%", left: 0, top: 0, overflow: "hidden", opacity: 0 } ); vimeo_player.playerBox = jQuery( "