/*___________________________________________________________________________________________________________________________________________________ _ jquery.mb.components _ _ _ _ file: jquery.mb.ytplayer.src.js _ _ last modified: 01/07/15 19.35 _ _ _ _ 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-2015. matteo bicocchi (pupunzi); _ ___________________________________________________________________________________________________________________________________________________*/ var ytp = ytp || {}; function onyoutubeiframeapiready() { if( ytp.ytapiready ) return; ytp.ytapiready = true; jquery( document ).trigger( "ytapiready" ); } var getytpvideoid = function( url ) { var videoid, playlistid; if( url.indexof( "youtu.be" ) > 0 ) { videoid = url.substr( url.lastindexof( "/" ) + 1, url.length ); playlistid = videoid.indexof( "?list=" ) > 0 ? videoid.substr( videoid.lastindexof( "=" ), videoid.length ) : null; videoid = playlistid ? videoid.substr( 0, videoid.lastindexof( "?" ) ) : videoid; } else if( url.indexof( "http" ) > -1 ) { //videoid = url.match( /([\/&]v\/([^]*))|([\\?&]v=([^]*))/ )[ 1 ]; videoid = url.match( /[\\?&]v=([^]*)/ )[ 1 ]; playlistid = url.indexof( "list=" ) > 0 ? url.match( /[\\?&]list=([^]*)/ )[ 1 ] : null; } else { videoid = url.length > 15 ? null : url; playlistid = videoid ? null : url; } return { videoid: videoid, playlistid: playlistid }; }; ( function( jquery, ytp ) { jquery.mbytplayer = { name: "jquery.mb.ytplayer", version: "2.9.9", build: "5751", author: "matteo bicocchi", apikey: "", defaults: { containment: "body", ratio: "auto", // "auto", "16/9", "4/3" videourl: null, playlisturl: null, startat: 0, stopat: 0, autoplay: true, vol: 50, // 1 to 100 addraster: false, opacity: 1, quality: "default", //or 鈥渟mall鈥? 鈥渕edium鈥? 鈥渓arge鈥? 鈥渉d720鈥? 鈥渉d1080鈥? 鈥渉ighres鈥? mute: false, loop: true, showcontrols: true, showannotations: false, showytlogo: true, stopmovieonblur: true, realfullscreen: true, gatrack: true, optimizedisplay: true, onready: function( player ) {} }, /* @fontface icons */ controls: { play: "p", pause: "p", mute: "m", unmute: "a", onlyyt: "o", showsite: "r", ytlogo: "y" }, locationprotocol: "https:", /** * * @param options * @returns [players] */ buildplayer: function( options ) { return this.each( function() { var ytplayer = this; var $ytplayer = jquery( ytplayer ); ytplayer.loop = 0; ytplayer.opt = {}; ytplayer.state = {}; ytplayer.filtersenabled = true; ytplayer.filters = { grayscale: { value: 0, unit: "%" }, hue_rotate: { value: 0, unit: "deg" }, invert: { value: 0, unit: "%" }, opacity: { value: 0, unit: "%" }, saturate: { value: 0, unit: "%" }, sepia: { value: 0, unit: "%" }, brightness: { value: 0, unit: "%" }, contrast: { value: 0, unit: "%" }, blur: { value: 0, unit: "px" } }; $ytplayer.addclass( "mb_ytplayer" ); var property = $ytplayer.data( "property" ) && typeof $ytplayer.data( "property" ) == "string" ? eval( '(' + $ytplayer.data( "property" ) + ')' ) : $ytplayer.data( "property" ); if( typeof property != "undefined" && typeof property.vol != "undefined" ) property.vol = property.vol === 0 ? property.vol = 1 : property.vol; jquery.extend( ytplayer.opt, jquery.mbytplayer.defaults, options, property ); if( !ytplayer.haschanged ) { ytplayer.defaultopt = {}; jquery.extend( ytplayer.defaultopt, jquery.mbytplayer.defaults, options, property ); } if( ytplayer.opt.loop == "true" ) ytplayer.opt.loop = 9999; ytplayer.isretina = ( window.retina || window.devicepixelratio > 1 ); var isiframe = function() { var isifr = false; try { if( self.location.href != top.location.href ) isifr = true; } catch( e ) { isifr = true; } return isifr; }; ytplayer.cangofullscreen = !( jquery.browser.msie || jquery.browser.opera || isiframe() ); if( !ytplayer.cangofullscreen ) ytplayer.opt.realfullscreen = false; if( !$ytplayer.attr( "id" ) ) $ytplayer.attr( "id", "video_" + new date().gettime() ); var playerid = "mbytp_" + ytplayer.id; ytplayer.isalone = false; ytplayer.hasfocus = true; var videoid = this.opt.videourl ? getytpvideoid( this.opt.videourl ).videoid : $ytplayer.attr( "href" ) ? getytpvideoid( $ytplayer.attr( "href" ) ).videoid : false; var playlistid = this.opt.videourl ? getytpvideoid( this.opt.videourl ).playlistid : $ytplayer.attr( "href" ) ? getytpvideoid( $ytplayer.attr( "href" ) ).playlistid : false; ytplayer.videoid = videoid; ytplayer.playlistid = playlistid; ytplayer.opt.showannotations = ( ytplayer.opt.showannotations ) ? '0' : '3'; var playervars = { 'autoplay': 0, 'modestbranding': 1, 'controls': 0, 'showinfo': 0, 'rel': 0, 'enablejsapi': 1, 'version': 3, 'playerapiid': playerid, 'origin': '*', 'allowfullscreen': true, 'wmode': 'transparent', 'iv_load_policy': ytplayer.opt.showannotations }; if( document.createelement( 'video' ).canplaytype ) jquery.extend( playervars, { 'html5': 1 } ); if( jquery.browser.msie && jquery.browser.version < 9 ) this.opt.opacity = 1; var playerbox = jquery( "
" ).attr( "id", playerid ).addclass( "playerbox" ); var overlay = jquery( "" ).css( { position: "absolute", top: 0, left: 0, width: "100%", height: "100%" } ).addclass( "ytpoverlay" ); ytplayer.isself = ytplayer.opt.containment == "self"; ytplayer.defaultopt.containment = ytplayer.opt.containment = ytplayer.opt.containment == "self" ? jquery( this ) : jquery( ytplayer.opt.containment ); ytplayer.isbackground = ytplayer.opt.containment.get( 0 ).tagname.tolowercase() == "body"; if( ytplayer.isbackground && ytp.backgroundisinited ) return; var isplayer = ytplayer.opt.containment.is( jquery( this ) ); ytplayer.canplayonmobile = isplayer && jquery( this ).children().length === 0; if( !isplayer ) { $ytplayer.hide(); } else { ytplayer.isplayer = true; } if( jquery.browser.mobile && !ytplayer.canplayonmobile ) { $ytplayer.remove(); return; } var wrapper = jquery( "" ).addclass( "mbytp_wrapper" ).attr( "id", "wrapper_" + playerid ); wrapper.css( { position: "absolute", zindex: 0, minwidth: "100%", minheight: "100%", left: 0, top: 0, overflow: "hidden", opacity: 0 } ); playerbox.css( { position: "absolute", zindex: 0, width: "100%", height: "100%", top: 0, left: 0, overflow: "hidden" } ); wrapper.append( playerbox ); ytplayer.opt.containment.children().not( "script, style" ).each( function() { if( jquery( this ).css( "position" ) == "static" ) jquery( this ).css( "position", "relative" ); } ); if( ytplayer.isbackground ) { jquery( "body" ).css( { boxsizing: "border-box" } ); wrapper.css( { position: "fixed", top: 0, left: 0, zindex: 0 } ); $ytplayer.hide(); } else if( ytplayer.opt.containment.css( "position" ) == "static" ) ytplayer.opt.containment.css( { position: "relative" } ); ytplayer.opt.containment.prepend( wrapper ); ytplayer.wrapper = wrapper; playerbox.css( { opacity: 1 } ); if( !jquery.browser.mobile ) { playerbox.after( overlay ); ytplayer.overlay = overlay; } if( !ytplayer.isbackground ) { overlay.on( "mouseenter", function() { if( ytplayer.controlbar ) ytplayer.controlbar.addclass( "visible" ); } ).on( "mouseleave", function() { if( ytplayer.controlbar ) ytplayer.controlbar.removeclass( "visible" ); } ); } if( !ytp.ytapiready ) { jquery( "#ytapi" ).remove(); var tag = jquery( "" ).attr( { "src": jquery.mbytplayer.locationprotocol + "//www.youtube.com/iframe_api?v=" + jquery.mbytplayer.version, "id": "ytapi" } ); jquery( "head" ).prepend( tag ); } else { settimeout( function() { jquery( document ).trigger( "ytapiready" ); }, 100 ) } jquery( document ).on( "ytapiready", function() { if( ( ytplayer.isbackground && ytp.backgroundisinited ) || ytplayer.isinit ) return; if( ytplayer.isbackground ) { ytp.backgroundisinited = true; } ytplayer.opt.autoplay = typeof ytplayer.opt.autoplay == "undefined" ? ( ytplayer.isbackground ? true : false ) : ytplayer.opt.autoplay; ytplayer.opt.vol = ytplayer.opt.vol ? ytplayer.opt.vol : 100; jquery.mbytplayer.getdatafromapi( ytplayer ); jquery( ytplayer ).on( "ytpchanged", function() { if( ytplayer.isinit ) return; ytplayer.isinit = true; //if is mobile && isplayer fallback to the default yt player if( jquery.browser.mobile && ytplayer.canplayonmobile ) { // try to adjust the player dimention if( ytplayer.opt.containment.outerwidth() > jquery( window ).width() ) { ytplayer.opt.containment.css( { maxwidth: "100%" } ); var h = ytplayer.opt.containment.outerwidth() * .6; ytplayer.opt.containment.css( { maxheight: h } ); } new yt.player( playerid, { videoid: ytplayer.videoid.tostring(), height: '100%', width: '100%', events: { 'onready': function( event ) { ytplayer.player = event.target; playerbox.css( { opacity: 1 } ); ytplayer.wrapper.css( { opacity: 1 } ); } } } ); return; } new yt.player( playerid, { videoid: ytplayer.videoid.tostring(), playervars: playervars, events: { 'onready': function( event ) { ytplayer.player = event.target; if( ytplayer.isready ) return; ytplayer.isready = ytplayer.isplayer && !ytplayer.opt.autoplay ? false : true; ytplayer.playerel = ytplayer.player.getiframe(); jquery( ytplayer.playerel ).unselectable(); $ytplayer.optimizedisplay(); ytplayer.videoid = videoid; jquery( window ).on( "resize.ytp", function() { $ytplayer.optimizedisplay(); } ); jquery.mbytplayer.checkforstate( ytplayer ); // trigger state events /* var ytpevent = jquery.event( "ytpunstarted" ); ytpevent.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpevent ); */ }, /** * * @param event * * -1 (unstarted) * 0 (ended) * 1 (playing) * 2 (paused) * 3 (buffering) * 5 (video cued). * * */ 'onstatechange': function( event ) { if( typeof event.target.getplayerstate != "function" ) return; var state = event.target.getplayerstate(); if( ytplayer.state == state ) return; if( ytplayer.preventtrigger ) { ytplayer.preventtrigger = false; return } ytplayer.state = state; var eventtype; switch( state ) { case -1: //----------------------------------------------- unstarted eventtype = "ytpunstarted"; break; case 0: //------------------------------------------------ ended eventtype = "ytpend"; break; case 1: //------------------------------------------------ play eventtype = "ytpplay"; if( ytplayer.controlbar ) ytplayer.controlbar.find( ".mb_ytpplaypause" ).html( jquery.mbytplayer.controls.pause ); if( typeof _gaq != "undefined" && eval( ytplayer.opt.gatrack ) ) _gaq.push( [ '_trackevent', 'ytplayer', 'play', ( ytplayer.hasdata ? ytplayer.videodata.title : ytplayer.videoid.tostring() ) ] ); if( typeof ga != "undefined" && eval( ytplayer.opt.gatrack ) ) ga( 'send', 'event', 'ytplayer', 'play', ( ytplayer.hasdata ? ytplayer.videodata.title : ytplayer.videoid.tostring() ) ); break; case 2: //------------------------------------------------ pause eventtype = "ytppause"; if( ytplayer.controlbar ) ytplayer.controlbar.find( ".mb_ytpplaypause" ).html( jquery.mbytplayer.controls.play ); break; case 3: //------------------------------------------------ buffer ytplayer.player.setplaybackquality( ytplayer.opt.quality ); eventtype = "ytpbuffering"; if( ytplayer.controlbar ) ytplayer.controlbar.find( ".mb_ytpplaypause" ).html( jquery.mbytplayer.controls.play ); break; case 5: //------------------------------------------------ cued eventtype = "ytpcued"; break; default: break; } // trigger state events var ytpevent = jquery.event( eventtype ); ytpevent.time = ytplayer.player.time; if( ytplayer.cantrigger ) jquery( ytplayer ).trigger( ytpevent ); }, /** * * @param e */ 'onplaybackqualitychange': function( e ) { var quality = e.target.getplaybackquality(); var ytpqualitychange = jquery.event( "ytpqualitychange" ); ytpqualitychange.quality = quality; jquery( ytplayer ).trigger( ytpqualitychange ); }, /** * * @param err */ 'onerror': function( err ) { if( err.data == 150 ) { console.log( "embedding this video is restricted by youtube." ); if( ytplayer.isplaylist ) jquery( ytplayer ).playnext(); } if( err.data == 2 && ytplayer.isplaylist ) jquery( ytplayer ).playnext(); if( typeof ytplayer.opt.onerror == "function" ) ytplayer.opt.onerror( $ytplayer, err ); } } } ); } ); } ) } ); }, /** * * @param ytplayer */ getdatafromapi: function( ytplayer ) { ytplayer.videodata = jquery.mbstorage.get( "ytplayer_data_" + ytplayer.videoid ); jquery( ytplayer ).off( "ytpdata.ytplayer" ).on( "ytpdata.ytplayer", function() { if( ytplayer.hasdata ) { if( ytplayer.isplayer && !ytplayer.opt.autoplay ) { var bgndurl = ytplayer.videodata.thumb_max || ytplayer.videodata.thumb_high || ytplayer.videodata.thumb_medium; ytplayer.opt.containment.css( { background: "rgba(0,0,0,0.5) url(" + bgndurl + ") center center", backgroundsize: "cover" } ); ytplayer.opt.backgroundurl = bgndurl; } } } ); if( ytplayer.videodata ) { settimeout( function() { ytplayer.opt.ratio = ytplayer.opt.ratio == "auto" ? "16/9" : ytplayer.opt.ratio; ytplayer.datareceived = true; jquery( ytplayer ).trigger( "ytpchanged" ); var ytpdata = jquery.event( "ytpdata" ); ytpdata.prop = {}; for( var x in ytplayer.videodata ) ytpdata.prop[ x ] = ytplayer.videodata[ x ]; jquery( ytplayer ).trigger( ytpdata ); }, 500 ); ytplayer.hasdata = true; } else if( jquery.mbytplayer.apikey ) { // get video info from api3 (needs api key) // snippet,player,contentdetails,statistics,status jquery.getjson( jquery.mbytplayer.locationprotocol + "//www.googleapis.com/youtube/v3/videos?id=" + ytplayer.videoid + "&key=" + jquery.mbytplayer.apikey + "&part=snippet", function( data ) { ytplayer.datareceived = true; jquery( ytplayer ).trigger( "ytpchanged" ); function parseytplayer_data( data ) { ytplayer.videodata = {}; ytplayer.videodata.id = ytplayer.videoid; ytplayer.videodata.channeltitle = data.channeltitle; ytplayer.videodata.title = data.title; ytplayer.videodata.description = data.description.length < 400 ? data.description : data.description.substring( 0, 400 ) + " ..."; ytplayer.videodata.aspectratio = ytplayer.opt.ratio == "auto" ? "16/9" : ytplayer.opt.ratio; ytplayer.opt.ratio = ytplayer.videodata.aspectratio; ytplayer.videodata.thumb_max = data.thumbnails.maxres ? data.thumbnails.maxres.url : null; ytplayer.videodata.thumb_high = data.thumbnails.high ? data.thumbnails.high.url : null; ytplayer.videodata.thumb_medium = data.thumbnails.medium ? data.thumbnails.medium.url : null; jquery.mbstorage.set( "ytplayer_data_" + ytplayer.videoid, ytplayer.videodata ); } parseytplayer_data( data.items[ 0 ].snippet ); ytplayer.hasdata = true; var ytpdata = jquery.event( "ytpdata" ); ytpdata.prop = {}; for( var x in ytplayer.videodata ) ytpdata.prop[ x ] = ytplayer.videodata[ x ]; jquery( ytplayer ).trigger( ytpdata ); } ); } else { settimeout( function() { jquery( ytplayer ).trigger( "ytpchanged" ); }, 50 ); if( ytplayer.isplayer && !ytplayer.opt.autoplay ) { var bgndurl = jquery.mbytplayer.locationprotocol + "//i.ytimg.com/vi/" + ytplayer.videoid + "/hqdefault.jpg"; ytplayer.opt.containment.css( { background: "rgba(0,0,0,0.5) url(" + bgndurl + ") center center", backgroundsize: "cover" } ); ytplayer.opt.backgroundurl = bgndurl; } ytplayer.videodata = null; ytplayer.opt.ratio = ytplayer.opt.ratio == "auto" ? "16/9" : ytplayer.opt.ratio; } if( ytplayer.isplayer && !ytplayer.opt.autoplay ) { ytplayer.loading = jquery( "" ).addclass( "loading" ).html( "loading" ).hide(); jquery( ytplayer ).append( ytplayer.loading ); ytplayer.loading.fadein(); } }, /** * */ removestoreddata: function() { jquery.mbstorage.remove(); }, /** * * @returns {*|ytplayer.videodata} */ getvideodata: function() { var ytplayer = this.get( 0 ); return ytplayer.videodata; }, /** * * @returns {*|ytplayer.videoid|boolean} */ getvideoid: function() { var ytplayer = this.get( 0 ); return ytplayer.videoid || false; }, /** * * @param quality */ setvideoquality: function( quality ) { var ytplayer = this.get( 0 ); if( !jquery.browser.chrome ) ytplayer.player.setplaybackquality( quality ); }, /** * @param videos * @param shuffle * @param callback * @returns {jquery.mbytplayer} */ playlist: function( videos, shuffle, callback ) { var $ytplayer = this; var ytplayer = $ytplayer.get( 0 ); ytplayer.isplaylist = true; if( shuffle ) videos = jquery.shuffle( videos ); if( !ytplayer.videoid ) { ytplayer.videos = videos; ytplayer.videocounter = 0; ytplayer.videolength = videos.length; jquery( ytplayer ).data( "property", videos[ 0 ] ); jquery( ytplayer ).mb_ytplayer(); } if( typeof callback == "function" ) jquery( ytplayer ).one( "ytpchanged", function() { callback( ytplayer ); } ); jquery( ytplayer ).on( "ytpend", function() { jquery( ytplayer ).playnext(); } ); return $ytplayer; }, /** * * @returns {jquery.mbytplayer} */ playnext: function() { var ytplayer = this.get( 0 ); ytplayer.videocounter++; if( ytplayer.videocounter >= ytplayer.videolength ) ytplayer.videocounter = 0; jquery( ytplayer ).changemovie( ytplayer.videos[ ytplayer.videocounter ] ); return this; }, /** * * @returns {jquery.mbytplayer} */ playprev: function() { var ytplayer = this.get( 0 ); ytplayer.videocounter--; if( ytplayer.videocounter < 0 ) ytplayer.videocounter = ytplayer.videolength - 1; jquery( ytplayer ).changemovie( ytplayer.videos[ ytplayer.videocounter ] ); return this; }, /** * * @param opt */ changemovie: function( opt ) { var ytplayer = this.get( 0 ); ytplayer.opt.startat = 0; ytplayer.opt.stopat = 0; ytplayer.opt.mute = true; ytplayer.hasdata = false; ytplayer.haschanged = true; ytplayer.player.looptime = undefined; if( opt ) jquery.extend( ytplayer.opt, ytplayer.defaultopt, opt ); ytplayer.videoid = getytpvideoid( ytplayer.opt.videourl ).videoid; if( ytplayer.opt.loop == "true" ) ytplayer.opt.loop = 9999; jquery( ytplayer.playerel ).cssanimate( { opacity: 0 }, 200, function() { var ytpchangemovie = jquery.event( "ytpchangemovie" ); ytpchangemovie.time = ytplayer.player.time; ytpchangemovie.videoid = ytplayer.videoid; jquery( ytplayer ).trigger( ytpchangemovie ); jquery( ytplayer ).ytpgetplayer().cuevideobyurl( encodeuri( jquery.mbytplayer.locationprotocol + "//www.youtube.com/v/" + ytplayer.videoid ), 1, ytplayer.opt.quality ); jquery( ytplayer ).optimizedisplay(); jquery.mbytplayer.checkforstate( ytplayer ); jquery.mbytplayer.getdatafromapi( ytplayer ); return this; } ); }, /** * * @returns {player} */ getplayer: function() { return jquery( this ).get( 0 ).player; }, playerdestroy: function() { var ytplayer = this.get( 0 ); ytp.ytapiready = false; ytp.backgroundisinited = false; ytplayer.isinit = false; ytplayer.videoid = null; var playerbox = ytplayer.wrapper; playerbox.remove(); jquery( "#controlbar_" + ytplayer.id ).remove(); clearinterval( ytplayer.checkforstartat ); clearinterval( ytplayer.getstate ); return this; }, /** * * @param real * @returns {jquery.mbytplayer} */ fullscreen: function( real ) { var ytplayer = this.get( 0 ); if( typeof real == "undefined" ) real = ytplayer.opt.realfullscreen; real = eval( real ); var controls = jquery( "#controlbar_" + ytplayer.id ); var fullscreenbtn = controls.find( ".mb_onlyyt" ); var videowrapper = ytplayer.isself ? ytplayer.opt.containment : ytplayer.wrapper; //var videowrapper = ytplayer.wrapper; if( real ) { var fullscreenchange = jquery.browser.mozilla ? "mozfullscreenchange" : jquery.browser.webkit ? "webkitfullscreenchange" : "fullscreenchange"; jquery( document ).off( fullscreenchange ).on( fullscreenchange, function() { var isfullscreen = runprefixmethod( document, "isfullscreen" ) || runprefixmethod( document, "fullscreen" ); if( !isfullscreen ) { ytplayer.isalone = false; fullscreenbtn.html( jquery.mbytplayer.controls.onlyyt ); jquery( ytplayer ).ytpsetvideoquality( ytplayer.opt.quality ); videowrapper.removeclass( "fullscreen" ); videowrapper.cssanimate( { opacity: ytplayer.opt.opacity }, 500 ); videowrapper.css( { zindex: 0 } ); if( ytplayer.isbackground ) { jquery( "body" ).after( controls ); } else { ytplayer.wrapper.before( controls ); } jquery( window ).resize(); jquery( ytplayer ).trigger( "ytpfullscreenend" ); } else { jquery( ytplayer ).ytpsetvideoquality( "default" ); jquery( ytplayer ).trigger( "ytpfullscreenstart" ); } } ); } if( !ytplayer.isalone ) { function hidemouse() { ytplayer.overlay.css( { cursor: "none" } ); } jquery( document ).on( "mousemove.ytplayer", function( e ) { ytplayer.overlay.css( { cursor: "auto" } ); cleartimeout( ytplayer.hidecursor ); if( !jquery( e.target ).parents().is( ".mb_ytpbar" ) ) ytplayer.hidecursor = settimeout( hidemouse, 3000 ); } ); hidemouse(); if( real ) { videowrapper.css( { opacity: 0 } ); videowrapper.addclass( "fullscreen" ); launchfullscreen( videowrapper.get( 0 ) ); settimeout( function() { videowrapper.cssanimate( { opacity: 1 }, 1000 ); ytplayer.wrapper.append( controls ); jquery( ytplayer ).optimizedisplay(); ytplayer.player.seekto( ytplayer.player.getcurrenttime() + .1, true ); }, 500 ) } else videowrapper.css( { zindex: 10000 } ).cssanimate( { opacity: 1 }, 1000 ); fullscreenbtn.html( jquery.mbytplayer.controls.showsite ); ytplayer.isalone = true; } else { jquery( document ).off( "mousemove.ytplayer" ); ytplayer.overlay.css( { cursor: "auto" } ); if( real ) { cancelfullscreen(); } else { videowrapper.cssanimate( { opacity: ytplayer.opt.opacity }, 500 ); videowrapper.css( { zindex: 0 } ); } fullscreenbtn.html( jquery.mbytplayer.controls.onlyyt ); ytplayer.isalone = false; } function runprefixmethod( obj, method ) { var pfx = [ "webkit", "moz", "ms", "o", "" ]; var p = 0, m, t; while( p < pfx.length && !obj[ m ] ) { m = method; if( pfx[ p ] == "" ) { m = m.substr( 0, 1 ).tolowercase() + m.substr( 1 ); } m = pfx[ p ] + m; t = typeof obj[ m ]; if( t != "undefined" ) { pfx = [ pfx[ p ] ]; return( t == "function" ? obj[ m ]() : obj[ m ] ); } p++; } } function launchfullscreen( element ) { runprefixmethod( element, "requestfullscreen" ); } function cancelfullscreen() { if( runprefixmethod( document, "fullscreen" ) || runprefixmethod( document, "isfullscreen" ) ) { runprefixmethod( document, "cancelfullscreen" ); } } return this; }, /** * * @returns {jquery.mbytplayer} */ toggleloops: function() { var ytplayer = this.get( 0 ); var data = ytplayer.opt; if( data.loop == 1 ) { data.loop = 0; } else { if( data.startat ) { ytplayer.player.seekto( data.startat ); } else { ytplayer.player.playvideo(); } data.loop = 1; } return this; }, /** * * @returns {jquery.mbytplayer} */ play: function() { var ytplayer = this.get( 0 ); if( !ytplayer.isready ) return; ytplayer.player.playvideo(); ytplayer.wrapper.cssanimate( { opacity: ytplayer.isalone ? 1 : ytplayer.opt.opacity }, 2000 ); jquery( ytplayer.playerel ).cssanimate( { opacity: 1 }, 1000 ); jquery( ytplayer ).css( "background-image", "none" ); return this; }, /** * * @param callback * @returns {jquery.mbytplayer} */ toggleplay: function( callback ) { var ytplayer = this.get( 0 ); if( ytplayer.state == 1 ) this.ytppause(); else this.ytpplay(); if( typeof callback == "function" ) { callback( ytplayer.state ); } return this; }, /** * * @returns {jquery.mbytplayer} */ stop: function() { var ytplayer = this.get( 0 ); var controls = jquery( "#controlbar_" + ytplayer.id ); var playbtn = controls.find( ".mb_ytpplaypause" ); playbtn.html( jquery.mbytplayer.controls.play ); ytplayer.player.stopvideo(); return this; }, /** * * @returns {jquery.mbytplayer} */ pause: function() { var ytplayer = this.get( 0 ); ytplayer.player.pausevideo(); return this; }, /** * * @param val * @returns {jquery.mbytplayer} */ seekto: function( val ) { var ytplayer = this.get( 0 ); ytplayer.player.seekto( val, true ); return this; }, /** * * @param val * @returns {jquery.mbytplayer} */ setvolume: function( val ) { var ytplayer = this.get( 0 ); if( !val && !ytplayer.opt.vol && ytplayer.player.getvolume() == 0 ) jquery( ytplayer ).ytpunmute(); else if( ( !val && ytplayer.player.getvolume() > 0 ) || ( val && ytplayer.opt.vol == val ) ) { if( !ytplayer.ismute ) jquery( ytplayer ).ytpmute(); else jquery( ytplayer ).ytpunmute(); } else { ytplayer.opt.vol = val; ytplayer.player.setvolume( ytplayer.opt.vol ); if( ytplayer.volumebar && ytplayer.volumebar.length ) ytplayer.volumebar.updatesliderval( val ) } return this; }, /** * * @returns {jquery.mbytplayer} */ mute: function() { var ytplayer = this.get( 0 ); if( ytplayer.ismute ) return; ytplayer.player.mute(); ytplayer.ismute = true; ytplayer.player.setvolume( 0 ); if( ytplayer.volumebar && ytplayer.volumebar.length && ytplayer.volumebar.width() > 10 ) { ytplayer.volumebar.updatesliderval( 0 ); } var controls = jquery( "#controlbar_" + ytplayer.id ); var mutebtn = controls.find( ".mb_ytpmuteunmute" ); mutebtn.html( jquery.mbytplayer.controls.unmute ); jquery( ytplayer ).addclass( "ismuted" ); if( ytplayer.volumebar && ytplayer.volumebar.length ) ytplayer.volumebar.addclass( "muted" ); var ytpevent = jquery.event( "ytpmuted" ); ytpevent.time = ytplayer.player.time; if( ytplayer.cantrigger ) jquery( ytplayer ).trigger( ytpevent ); return this; }, /** * * @returns {jquery.mbytplayer} */ unmute: function() { var ytplayer = this.get( 0 ); if( !ytplayer.ismute ) return; ytplayer.player.unmute(); ytplayer.ismute = false; ytplayer.player.setvolume( ytplayer.opt.vol ); if( ytplayer.volumebar && ytplayer.volumebar.length ) ytplayer.volumebar.updatesliderval( ytplayer.opt.vol > 10 ? ytplayer.opt.vol : 10 ); var controls = jquery( "#controlbar_" + ytplayer.id ); var mutebtn = controls.find( ".mb_ytpmuteunmute" ); mutebtn.html( jquery.mbytplayer.controls.mute ); jquery( ytplayer ).removeclass( "ismuted" ); if( ytplayer.volumebar && ytplayer.volumebar.length ) ytplayer.volumebar.removeclass( "muted" ); var ytpevent = jquery.event( "ytpunmuted" ); ytpevent.time = ytplayer.player.time; if( ytplayer.cantrigger ) jquery( ytplayer ).trigger( ytpevent ); return this; }, /** * * @param filter * @param value * @returns {jquery.mbytplayer} */ applyfilter: function( filter, value ) { var ytplayer = this.get( 0 ); ytplayer.filters[ filter ].value = value; if( ytplayer.filtersenabled ) this.ytpenablefilters(); return this; }, /** * * @param filters * @returns {jquery.mbytplayer} */ applyfilters: function( filters ) { var ytplayer = this.get( 0 ); this.on( "ytpready", function() { for( var key in filters ) { ytplayer.filters[ key ].value = filters[ key ]; jquery( ytplayer ).ytpapplyfilter( key, filters[ key ] ); } jquery( ytplayer ).trigger( "ytpfiltersapplied" ); } ); return this; }, /** * * @param filter * @param value * @returns {*} */ togglefilter: function( filter, value ) { return this.each( function() { var ytplayer = this; if( !ytplayer.filters[ filter ].value ) ytplayer.filters[ filter ].value = value; else ytplayer.filters[ filter ].value = 0; if( ytplayer.filtersenabled ) jquery( this ).ytpenablefilters(); } ) return this; }, /** * * @param callback * @returns {*} */ togglefilters: function( callback ) { return this.each( function() { var ytplayer = this; if( ytplayer.filtersenabled ) { jquery( ytplayer ).trigger( "ytpdisablefilters" ); jquery( ytplayer ).ytpdisablefilters(); } else { jquery( ytplayer ).ytpenablefilters(); jquery( ytplayer ).trigger( "ytpenablefilters" ); } if( typeof callback == "function" ) callback( ytplayer.filtersenabled ); } ) }, /** * * @returns {*} */ disablefilters: function() { return this.each( function() { var ytplayer = this; var iframe = jquery( ytplayer.playerel ); iframe.css( "-webkit-filter", "" ); iframe.css( "filter", "" ); ytplayer.filtersenabled = false; } ) }, /** * * @returns {*} */ enablefilters: function() { return this.each( function() { var ytplayer = this; var iframe = jquery( ytplayer.playerel ); var filterstyle = ""; for( var key in ytplayer.filters ) { if( ytplayer.filters[ key ].value ) filterstyle += key.replace( "_", "-" ) + "(" + ytplayer.filters[ key ].value + ytplayer.filters[ key ].unit + ") "; } iframe.css( "-webkit-filter", filterstyle ); iframe.css( "filter", filterstyle ); ytplayer.filtersenabled = true; } ) return this; }, /** * * @param filter * @param callback * @returns {*} */ removefilter: function( filter, callback ) { return this.each( function() { if( typeof filter == "function" ) { callback = filter; filter = null; } var ytplayer = this; if( !filter ) for( var key in ytplayer.filters ) { jquery( this ).ytpapplyfilter( key, 0 ); if( typeof callback == "function" ) callback( key ); } else { jquery( this ).ytpapplyfilter( filter, 0 ); if( typeof callback == "function" ) callback( filter ); } } ); return this; }, /** * * @returns {{totaltime: number, currenttime: number}} */ manageprogress: function() { var ytplayer = this.get( 0 ); var controls = jquery( "#controlbar_" + ytplayer.id ); var progressbar = controls.find( ".mb_ytpprogress" ); var loadedbar = controls.find( ".mb_ytploaded" ); var timebar = controls.find( ".mb_ytpseekbar" ); var totw = progressbar.outerwidth(); var currenttime = math.floor( ytplayer.player.getcurrenttime() ); var totaltime = math.floor( ytplayer.player.getduration() ); var timew = ( currenttime * totw ) / totaltime; var startleft = 0; var loadedw = ytplayer.player.getvideoloadedfraction() * 100; loadedbar.css( { left: startleft, width: loadedw + "%" } ); timebar.css( { left: 0, width: timew } ); return { totaltime: totaltime, currenttime: currenttime }; }, /** * * @param ytplayer */ buildcontrols: function( ytplayer ) { var data = ytplayer.opt; // @data.printurl: is deprecated; use data.showytlogo data.showytlogo = data.showytlogo || data.printurl; if( jquery( "#controlbar_" + ytplayer.id ).length ) return; ytplayer.controlbar = jquery( "" ).attr( "id", "controlbar_" + ytplayer.id ).addclass( "mb_ytpbar" ).css( { whitespace: "nowrap", position: ytplayer.isbackground ? "fixed" : "absolute", zindex: ytplayer.isbackground ? 10000 : 1000 } ).hide(); var buttonbar = jquery( "" ).addclass( "buttonbar" ); /* play/pause button*/ var playpause = jquery( "" + jquery.mbytplayer.controls.play + "" ).addclass( "mb_ytpplaypause ytpicon" ).click( function() { if( ytplayer.player.getplayerstate() == 1 ) jquery( ytplayer ).ytppause(); else jquery( ytplayer ).ytpplay(); } ); /* mute/unmute button*/ var muteunmute = jquery( "" + jquery.mbytplayer.controls.mute + "" ).addclass( "mb_ytpmuteunmute ytpicon" ).click( function() { if( ytplayer.player.getvolume() == 0 ) { jquery( ytplayer ).ytpunmute(); } else { jquery( ytplayer ).ytpmute(); } } ); /* volume bar*/ var volumebar = jquery( "" ).addclass( "mb_ytpvolumebar" ).css( { display: "inline-block" } ); ytplayer.volumebar = volumebar; /* time elapsed */ var idx = jquery( "" ).addclass( "mb_ytptime" ); var vurl = data.videourl ? data.videourl : ""; if( vurl.indexof( "http" ) < 0 ) vurl = jquery.mbytplayer.locationprotocol + "//www.youtube.com/watch?v=" + data.videourl; var movieurl = jquery( "" ).html( jquery.mbytplayer.controls.ytlogo ).addclass( "mb_ytpurl ytpicon" ).attr( "title", "view on youtube" ).on( "click", function() { window.open( vurl, "viewonyt" ) } ); var onlyvideo = jquery( "" ).html( jquery.mbytplayer.controls.onlyyt ).addclass( "mb_onlyyt ytpicon" ).on( "click", function() { jquery( ytplayer ).ytpfullscreen( data.realfullscreen ); } ); var progressbar = jquery( "" ).addclass( "mb_ytpprogress" ).css( "position", "absolute" ).click( function( e ) { timebar.css( { width: ( e.clientx - timebar.offset().left ) } ); ytplayer.timew = e.clientx - timebar.offset().left; ytplayer.controlbar.find( ".mb_ytploaded" ).css( { width: 0 } ); var totaltime = math.floor( ytplayer.player.getduration() ); ytplayer.goto = ( timebar.outerwidth() * totaltime ) / progressbar.outerwidth(); ytplayer.player.seekto( parsefloat( ytplayer.goto ), true ); ytplayer.controlbar.find( ".mb_ytploaded" ).css( { width: 0 } ); } ); var loadedbar = jquery( "" ).addclass( "mb_ytploaded" ).css( "position", "absolute" ); var timebar = jquery( "" ).addclass( "mb_ytpseekbar" ).css( "position", "absolute" ); progressbar.append( loadedbar ).append( timebar ); buttonbar.append( playpause ).append( muteunmute ).append( volumebar ).append( idx ); if( data.showytlogo ) { buttonbar.append( movieurl ); } if( ytplayer.isbackground || ( eval( ytplayer.opt.realfullscreen ) && !ytplayer.isbackground ) ) buttonbar.append( onlyvideo ); ytplayer.controlbar.append( buttonbar ).append( progressbar ); if( !ytplayer.isbackground ) { ytplayer.controlbar.addclass( "inlineplayer" ); ytplayer.wrapper.before( ytplayer.controlbar ); } else { jquery( "body" ).after( ytplayer.controlbar ); } volumebar.simpleslider( { initialval: ytplayer.opt.vol, scale: 100, orientation: "h", callback: function( el ) { if( el.value == 0 ) { jquery( ytplayer ).ytpmute(); } else { jquery( ytplayer ).ytpunmute(); } ytplayer.player.setvolume( el.value ); if( !ytplayer.ismute ) ytplayer.opt.vol = el.value; } } ); }, /** * * * */ checkforstate: function( ytplayer ) { var interval = ytplayer.opt.showcontrols ? 100 : 400; clearinterval( ytplayer.getstate ); //checking if player has been removed from scene if( !jquery.contains( document, ytplayer ) ) { jquery( ytplayer ).ytpplayerdestroy(); clearinterval( ytplayer.getstate ); clearinterval( ytplayer.checkforstartat ); return; } jquery.mbytplayer.checkforstart( ytplayer ); ytplayer.getstate = setinterval( function() { var prog = jquery( ytplayer ).ytpmanageprogress(); var $ytplayer = jquery( ytplayer ); var data = ytplayer.opt; var startat = ytplayer.opt.startat ? ytplayer.opt.startat : 1; var stopat = ytplayer.opt.stopat > ytplayer.opt.startat ? ytplayer.opt.stopat : 0; stopat = stopat < ytplayer.player.getduration() ? stopat : 0; if( ytplayer.player.time != prog.currenttime ) { var ytpevent = jquery.event( "ytptime" ); ytpevent.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpevent ); } ytplayer.player.time = prog.currenttime; if( ytplayer.player.getvolume() == 0 ) $ytplayer.addclass( "ismuted" ); else $ytplayer.removeclass( "ismuted" ); if( ytplayer.opt.showcontrols ) if( prog.totaltime ) { ytplayer.controlbar.find( ".mb_ytptime" ).html( jquery.mbytplayer.formattime( prog.currenttime ) + " / " + jquery.mbytplayer.formattime( prog.totaltime ) ); } else { ytplayer.controlbar.find( ".mb_ytptime" ).html( "-- : -- / -- : --" ); } if( eval( ytplayer.opt.stopmovieonblur ) ) if( !document.hasfocus() ) { if( ytplayer.state == 1 ) { ytplayer.hasfocus = false; $ytplayer.ytppause(); } } else if( document.hasfocus() && !ytplayer.hasfocus && !( ytplayer.state == -1 || ytplayer.state == 0 ) ) { ytplayer.hasfocus = true; $ytplayer.ytpplay(); } if( ytplayer.controlbar && ytplayer.controlbar.outerwidth() <= 400 && !ytplayer.iscompact ) { ytplayer.controlbar.addclass( "compact" ); ytplayer.iscompact = true; if( !ytplayer.ismute && ytplayer.volumebar ) ytplayer.volumebar.updatesliderval( ytplayer.opt.vol ); } else if( ytplayer.controlbar && ytplayer.controlbar.outerwidth() > 400 && ytplayer.iscompact ) { ytplayer.controlbar.removeclass( "compact" ); ytplayer.iscompact = false; if( !ytplayer.ismute && ytplayer.volumebar ) ytplayer.volumebar.updatesliderval( ytplayer.opt.vol ); } if( ytplayer.player.getplayerstate() == 1 && ( parsefloat( ytplayer.player.getduration() - 1.5 ) < ytplayer.player.getcurrenttime() || ( stopat > 0 && parsefloat( ytplayer.player.getcurrenttime() ) > stopat ) ) ) { if( ytplayer.isended ) return; ytplayer.isended = true; settimeout( function() { ytplayer.isended = false }, 1000 ); if( ytplayer.isplaylist ) { if( !data.loop || ( data.loop > 0 && ytplayer.player.looptime === data.loop - 1 ) ) { ytplayer.player.looptime = undefined; clearinterval( ytplayer.getstate ); var ytpend = jquery.event( "ytpend" ); ytpend.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpend ); return; } } else if( !data.loop || ( data.loop > 0 && ytplayer.player.looptime === data.loop - 1 ) ) { ytplayer.player.looptime = undefined; ytplayer.preventtrigger = true; jquery( ytplayer ).ytppause(); ytplayer.wrapper.cssanimate( { opacity: 0 }, 1000, function() { var ytpend = jquery.event( "ytpend" ); ytpend.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpend ); ytplayer.player.seekto( startat, true ); if( !ytplayer.isbackground ) { ytplayer.opt.containment.css( { background: "rgba(0,0,0,0.5) url(" + ytplayer.opt.backgroundurl + ") center center", backgroundsize: "cover" } ); } } ); return; } ytplayer.player.looptime = ytplayer.player.looptime ? ++ytplayer.player.looptime : 1; startat = startat || 1; ytplayer.preventtrigger = true; jquery( ytplayer ).ytppause(); ytplayer.player.seekto( startat, true ); $ytplayer.ytpplay(); } }, interval ); }, /** * * */ checkforstart: function( ytplayer ) { var $ytplayer = jquery( ytplayer ); //checking if player has been removed from scene if( !jquery.contains( document, ytplayer ) ) { jquery( ytplayer ).ytpplayerdestroy(); return } if( jquery.browser.chrome ) ytplayer.opt.quality = "default"; ytplayer.preventtrigger = true; jquery( ytplayer ).ytppause(); jquery( ytplayer ).muteytpvolume(); jquery( "#controlbar_" + ytplayer.id ).remove(); if( ytplayer.opt.showcontrols ) jquery.mbytplayer.buildcontrols( ytplayer ); if( ytplayer.opt.addraster ) { var classn = ytplayer.opt.addraster == "dot" ? "raster-dot" : "raster"; ytplayer.overlay.addclass( ytplayer.isretina ? classn + " retina" : classn ); } else { ytplayer.overlay.removeclass( function( index, classnames ) { // change the list into an array var current_classes = classnames.split( " " ), // array of classes which are to be removed classes_to_remove = []; jquery.each( current_classes, function( index, class_name ) { // if the classname begins with bg add it to the classes_to_remove array if( /raster.*/.test( class_name ) ) { classes_to_remove.push( class_name ); } } ); classes_to_remove.push( "retina" ); // turn the array back into a string return classes_to_remove.join( " " ); } ) } ytplayer.checkforstartat = setinterval( function() { jquery( ytplayer ).ytpmute(); var startat = ytplayer.opt.startat ? ytplayer.opt.startat : 1; var canplayvideo = ( ytplayer.player.getvideoloadedfraction() > startat / ytplayer.player.getduration() ); if( ytplayer.player.getduration() > 0 && ytplayer.player.getcurrenttime() >= startat && canplayvideo ) { clearinterval( ytplayer.checkforstartat ); ytplayer.isready = true; if( typeof ytplayer.opt.onready == "function" ) ytplayer.opt.onready( ytplayer ); var ytpready = jquery.event( "ytpready" ); ytpready.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpready ); ytplayer.preventtrigger = true; jquery( ytplayer ).ytppause(); if( !ytplayer.opt.mute ) jquery( ytplayer ).ytpunmute(); ytplayer.cantrigger = true; if( ytplayer.opt.autoplay ) { $ytplayer.ytpplay(); var ytpstart = jquery.event( "ytpstart" ); ytpstart.time = ytplayer.player.time; jquery( ytplayer ).trigger( ytpstart ); $ytplayer.css( "background-image", "none" ); jquery( ytplayer.playerel ).cssanimate( { opacity: 1 }, 1000 ); ytplayer.wrapper.cssanimate( { opacity: ytplayer.isalone ? 1 : ytplayer.opt.opacity }, 1000 ); } else { ytplayer.player.pausevideo(); if( !ytplayer.isplayer ) { jquery( ytplayer.playerel ).cssanimate( { opacity: 1 }, 1000 ); ytplayer.wrapper.cssanimate( { opacity: ytplayer.isalone ? 1 : ytplayer.opt.opacity }, 1000 ); } } if( ytplayer.isplayer && !ytplayer.opt.autoplay ) { ytplayer.loading.html( "ready" ); settimeout( function() { ytplayer.loading.fadeout(); }, 100 ) } if( ytplayer.controlbar ) ytplayer.controlbar.slidedown( 1000 ); } else { //ytplayer.player.playvideo(); if( startat >= 0 ) ytplayer.player.seekto( startat, true ); } }, 1000 ); }, /** * * @param s * @returns {string} */ formattime: function( s ) { var min = math.floor( s / 60 ); var sec = math.floor( s - ( 60 * min ) ); return( min <= 9 ? "0" + min : min ) + " : " + ( sec <= 9 ? "0" + sec : sec ); } }; /** * * @returns {boolean} */ jquery.fn.togglevolume = function() { var ytplayer = this.get( 0 ); if( !ytplayer ) return; if( ytplayer.player.ismuted() ) { jquery( ytplayer ).ytpunmute(); return true; } else { jquery( ytplayer ).ytpmute(); return false; } }; /** * */ jquery.fn.optimizedisplay = function() { var ytplayer = this.get( 0 ); var data = ytplayer.opt; var playerbox = jquery( ytplayer.playerel ); var win = {}; var el = ytplayer.wrapper; win.width = el.outerwidth(); win.height = el.outerheight(); var margin = 24; var overprint = 100; var vid = {}; if( data.optimizedisplay ) { vid.width = win.width + ( ( win.width * margin ) / 100 ); vid.height = data.ratio == "16/9" ? math.ceil( ( 9 * win.width ) / 16 ) : math.ceil( ( 3 * win.width ) / 4 ); vid.margintop = -( ( vid.height - win.height ) / 2 ); vid.marginleft = -( ( win.width * ( margin / 2 ) ) / 100 ); if( vid.height < win.height ) { vid.height = win.height + ( ( win.height * margin ) / 100 ); vid.width = data.ratio == "16/9" ? math.floor( ( 16 * win.height ) / 9 ) : math.floor( ( 4 * win.height ) / 3 ); vid.margintop = -( ( win.height * ( margin / 2 ) ) / 100 ); vid.marginleft = -( ( vid.width - win.width ) / 2 ); } vid.width += overprint; vid.height += overprint; vid.margintop -= overprint / 2; vid.marginleft -= overprint / 2; } else { vid.width = "100%"; vid.height = "100%"; vid.margintop = 0; vid.marginleft = 0; } playerbox.css( { width: vid.width, height: vid.height, margintop: vid.margintop, marginleft: vid.marginleft } ); }; /** * * @param arr * @returns {array|string|blob|*} * */ jquery.shuffle = function( arr ) { var newarray = arr.slice(); var len = newarray.length; var i = len; while( i-- ) { var p = parseint( math.random() * len ); var t = newarray[ i ]; newarray[ i ] = newarray[ p ]; newarray[ p ] = t; } return newarray; }; jquery.fn.unselectable = function() { return this.each( function() { jquery( this ).css( { "-moz-user-select": "none", "-webkit-user-select": "none", "user-select": "none" } ).attr( "unselectable", "on" ); } ); }; /* exposed public method */ jquery.fn.ytplayer = jquery.mbytplayer.buildplayer; jquery.fn.ytpgetplayer = jquery.mbytplayer.getplayer; jquery.fn.ytpgetvideoid = jquery.mbytplayer.getvideoid; jquery.fn.ytpchangemovie = jquery.mbytplayer.changemovie; jquery.fn.ytpplayerdestroy = jquery.mbytplayer.playerdestroy; jquery.fn.ytpplay = jquery.mbytplayer.play; jquery.fn.ytptoggleplay = jquery.mbytplayer.toggleplay; jquery.fn.ytpstop = jquery.mbytplayer.stop; jquery.fn.ytppause = jquery.mbytplayer.pause; jquery.fn.ytpseekto = jquery.mbytplayer.seekto; jquery.fn.ytplaylist = jquery.mbytplayer.playlist; jquery.fn.ytpplaynext = jquery.mbytplayer.playnext; jquery.fn.ytpplayprev = jquery.mbytplayer.playprev; jquery.fn.ytpmute = jquery.mbytplayer.mute; jquery.fn.ytpunmute = jquery.mbytplayer.unmute; jquery.fn.ytptogglevolume = jquery.mbytplayer.togglevolume; jquery.fn.ytpsetvolume = jquery.mbytplayer.setvolume; jquery.fn.ytpgetvideodata = jquery.mbytplayer.getvideodata; jquery.fn.ytpfullscreen = jquery.mbytplayer.fullscreen; jquery.fn.ytptoggleloops = jquery.mbytplayer.toggleloops; jquery.fn.ytpsetvideoquality = jquery.mbytplayer.setvideoquality; jquery.fn.ytpmanageprogress = jquery.mbytplayer.manageprogress; jquery.fn.ytpapplyfilter = jquery.mbytplayer.applyfilter; jquery.fn.ytpapplyfilters = jquery.mbytplayer.applyfilters; jquery.fn.ytptogglefilter = jquery.mbytplayer.togglefilter; jquery.fn.ytptogglefilters = jquery.mbytplayer.togglefilters; jquery.fn.ytpremovefilter = jquery.mbytplayer.removefilter; jquery.fn.ytpdisablefilters = jquery.mbytplayer.disablefilters; jquery.fn.ytpenablefilters = jquery.mbytplayer.enablefilters; /** * * @deprecated * **/ jquery.fn.mb_ytplayer = jquery.mbytplayer.buildplayer; jquery.fn.playnext = jquery.mbytplayer.playnext; jquery.fn.playprev = jquery.mbytplayer.playprev; jquery.fn.changemovie = jquery.mbytplayer.changemovie; jquery.fn.getvideoid = jquery.mbytplayer.getvideoid; jquery.fn.getplayer = jquery.mbytplayer.getplayer; jquery.fn.playerdestroy = jquery.mbytplayer.playerdestroy; jquery.fn.fullscreen = jquery.mbytplayer.fullscreen; jquery.fn.buildytpcontrols = jquery.mbytplayer.buildcontrols; jquery.fn.playytp = jquery.mbytplayer.play; jquery.fn.toggleloops = jquery.mbytplayer.toggleloops; jquery.fn.stopytp = jquery.mbytplayer.stop; jquery.fn.pauseytp = jquery.mbytplayer.pause; jquery.fn.seektoytp = jquery.mbytplayer.seekto; jquery.fn.muteytpvolume = jquery.mbytplayer.mute; jquery.fn.unmuteytpvolume = jquery.mbytplayer.unmute; jquery.fn.setytpvolume = jquery.mbytplayer.setvolume; jquery.fn.setvideoquality = jquery.mbytplayer.setvideoquality; jquery.fn.manageytpprogress = jquery.mbytplayer.manageprogress; jquery.fn.ytpgetdatafromfeed = jquery.mbytplayer.getvideodata; } )( jquery, ytp ); ; /* * ****************************************************************************** * jquery.mb.components * file: jquery.mb.cssanimate.min.js * * copyright (c) 2001-2014. matteo bicocchi (pupunzi); * open lab srl, firenze - italy * email: matteo@open-lab.com * site: http://pupunzi.com * blog: http://pupunzi.open-lab.com * http://open-lab.com * * licences: mit, gpl * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * last modified: 26/03/14 21.40 * ***************************************************************************** */ function uncamel(a){return a.replace(/([a-z])/g,function(a){return"-"+a.tolowercase()})}function setunit(a,b){return"string"!=typeof a||a.match(/^[\-0-9\.]+jquery/)?""+a+b:a}function setfilter(a,b,c){var d=uncamel(b),e=jquery.browser.mozilla?"":jquery.css.sfx;a[e+"filter"]=a[e+"filter"]||"",c=setunit(c>jquery.css.filters[b].max?jquery.css.filters[b].max:c,jquery.css.filters[b].unit),a[e+"filter"]+=d+"("+c+") ",delete a[b]}jquery.support.csstransition=function(){var a=document.body||document.documentelement,b=a.style;return void 0!==b.transition||void 0!==b.webkittransition||void 0!==b.moztransition||void 0!==b.mstransition||void 0!==b.otransition}(),jquery.css={name:"mb.cssanimate",author:"matteo bicocchi",version:"2.0.0",transitionend:"transitionend",sfx:"",filters:{blur:{min:0,max:100,unit:"px"},brightness:{min:0,max:400,unit:"%"},contrast:{min:0,max:400,unit:"%"},grayscale:{min:0,max:100,unit:"%"},huerotate:{min:0,max:360,unit:"deg"},invert:{min:0,max:100,unit:"%"},saturate:{min:0,max:400,unit:"%"},sepia:{min:0,max:100,unit:"%"}},normalizecss:function(a){var b=jquery.extend(!0,{},a);jquery.browser.webkit||jquery.browser.opera?jquery.css.sfx="-webkit-":jquery.browser.mozilla?jquery.css.sfx="-moz-":jquery.browser.msie&&(jquery.css.sfx="-ms-");for(var c in b){"transform"===c&&(b[jquery.css.sfx+"transform"]=b[c],delete b[c]),"transform-origin"===c&&(b[jquery.css.sfx+"transform-origin"]=a[c],delete b[c]),"filter"!==c||jquery.browser.mozilla||(b[jquery.css.sfx+"filter"]=a[c],delete b[c]),"blur"===c&&setfilter(b,"blur",a[c]),"brightness"===c&&setfilter(b,"brightness",a[c]),"contrast"===c&&setfilter(b,"contrast",a[c]),"grayscale"===c&&setfilter(b,"grayscale",a[c]),"huerotate"===c&&setfilter(b,"huerotate",a[c]),"invert"===c&&setfilter(b,"invert",a[c]),"saturate"===c&&setfilter(b,"saturate",a[c]),"sepia"===c&&setfilter(b,"sepia",a[c]);var d="";"x"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" translatex("+setunit(a[c],"px")+")",delete b[c]),"y"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" translatey("+setunit(a[c],"px")+")",delete b[c]),"z"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" translatez("+setunit(a[c],"px")+")",delete b[c]),"rotate"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" rotate("+setunit(a[c],"deg")+")",delete b[c]),"rotatex"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" rotatex("+setunit(a[c],"deg")+")",delete b[c]),"rotatey"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" rotatey("+setunit(a[c],"deg")+")",delete b[c]),"rotatez"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" rotatez("+setunit(a[c],"deg")+")",delete b[c]),"scale"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" scale("+setunit(a[c],"")+")",delete b[c]),"scalex"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" scalex("+setunit(a[c],"")+")",delete b[c]),"scaley"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" scaley("+setunit(a[c],"")+")",delete b[c]),"scalez"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" scalez("+setunit(a[c],"")+")",delete b[c]),"skew"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" skew("+setunit(a[c],"deg")+")",delete b[c]),"skewx"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" skewx("+setunit(a[c],"deg")+")",delete b[c]),"skewy"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" skewy("+setunit(a[c],"deg")+")",delete b[c]),"perspective"===c&&(d=jquery.css.sfx+"transform",b[d]=b[d]||"",b[d]+=" perspective("+setunit(a[c],"px")+")",delete b[c])}return b},getprop:function(a){var b=[];for(var c in a)b.indexof(c)<0&&b.push(uncamel(c));return b.join(",")},animate:function(a,b,c,d,e){return this.each(function(){function o(){f.called=!0,f.cssaisrunning=!1,g.off(jquery.css.transitionend+"."+f.id),cleartimeout(f.timeout),g.css(jquery.css.sfx+"transition",""),"function"==typeof e&&e.apply(f),"function"==typeof f.cssqueue&&(f.cssqueue(),f.cssqueue=null)}var f=this,g=jquery(this);f.id=f.id||"cssa_"+(new date).gettime();var h=h||{type:"noevent"};if(f.cssaisrunning&&f.eventtype==h.type&&!jquery.browser.msie&&jquery.browser.version<=9)return f.cssqueue=function(){g.cssanimate(a,b,c,d,e)},void 0;if(f.cssqueue=null,f.eventtype=h.type,0!==g.length&&a){if(a=jquery.normalizecss(a),f.cssaisrunning=!0,"function"==typeof b&&(e=b,b=jquery.fx.speeds._default),"function"==typeof c&&(d=c,c=0),"string"==typeof c&&(e=c,c=0),"function"==typeof d&&(e=d,d="cubic-bezier(0.65,0.03,0.36,0.72)"),"string"==typeof b)for(var i in jquery.fx.speeds){if(b==i){b=jquery.fx.speeds[i];break}b=jquery.fx.speeds._default}if(b||(b=jquery.fx.speeds._default),"string"==typeof e&&(d=e,e=null),!jquery.support.csstransition){for(var j in a){if("transform"===j&&delete a[j],"filter"===j&&delete a[j],"transform-origin"===j&&delete a[j],"auto"===a[j]&&delete a[j],"x"===j){var k=a[j],l="left";a[l]=k,delete a[j]}if("y"===j){var k=a[j],l="top";a[l]=k,delete a[j]}("-ms-transform"===j||"-ms-filter"===j)&&delete a[j]}return g.delay(c).animate(a,b,e),void 0}var m={"default":"ease","in":"ease-in",out:"ease-out","in-out":"ease-in-out",snap:"cubic-bezier(0,1,.5,1)",easeoutcubic:"cubic-bezier(.215,.61,.355,1)",easeinoutcubic:"cubic-bezier(.645,.045,.355,1)",easeincirc:"cubic-bezier(.6,.04,.98,.335)",easeoutcirc:"cubic-bezier(.075,.82,.165,1)",easeinoutcirc:"cubic-bezier(.785,.135,.15,.86)",easeinexpo:"cubic-bezier(.95,.05,.795,.035)",easeoutexpo:"cubic-bezier(.19,1,.22,1)",easeinoutexpo:"cubic-bezier(1,0,0,1)",easeinquad:"cubic-bezier(.55,.085,.68,.53)",easeoutquad:"cubic-bezier(.25,.46,.45,.94)",easeinoutquad:"cubic-bezier(.455,.03,.515,.955)",easeinquart:"cubic-bezier(.895,.03,.685,.22)",easeoutquart:"cubic-bezier(.165,.84,.44,1)",easeinoutquart:"cubic-bezier(.77,0,.175,1)",easeinquint:"cubic-bezier(.755,.05,.855,.06)",easeoutquint:"cubic-bezier(.23,1,.32,1)",easeinoutquint:"cubic-bezier(.86,0,.07,1)",easeinsine:"cubic-bezier(.47,0,.745,.715)",easeoutsine:"cubic-bezier(.39,.575,.565,1)",easeinoutsine:"cubic-bezier(.445,.05,.55,.95)",easeinback:"cubic-bezier(.6,-.28,.735,.045)",easeoutback:"cubic-bezier(.175, .885,.32,1.275)",easeinoutback:"cubic-bezier(.68,-.55,.265,1.55)"};m[d]&&(d=m[d]),g.off(jquery.css.transitionend+"."+f.id);var n=jquery.css.getprop(a),p={};jquery.extend(p,a),p[jquery.css.sfx+"transition-property"]=n,p[jquery.css.sfx+"transition-duration"]=b+"ms",p[jquery.css.sfx+"transition-delay"]=c+"ms",p[jquery.css.sfx+"transition-timing-function"]=d,settimeout(function(){g.one(jquery.css.transitionend+"."+f.id,o),g.css(p)},1),f.timeout=settimeout(function(){return f.called||!e?(f.called=!1,f.cssaisrunning=!1,void 0):(g.css(jquery.css.sfx+"transition",""),e.apply(f),f.cssaisrunning=!1,"function"==typeof f.cssqueue&&(f.cssqueue(),f.cssqueue=null),void 0)},b+c+10)}})}},jquery.fn.cssanimate=jquery.css.animate,jquery.normalizecss=jquery.css.normalizecss,jquery.fn.css3=function(a){return this.each(function(){var b=jquery(this),c=jquery.normalizecss(a);b.css(c)})}; ;/* * ****************************************************************************** * jquery.mb.components * file: jquery.mb.browser.min.js * * copyright (c) 2001-2014. matteo bicocchi (pupunzi); * open lab srl, firenze - italy * email: matteo@open-lab.com * site: http://pupunzi.com * blog: http://pupunzi.open-lab.com * http://open-lab.com * * licences: mit, gpl * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * last modified: 26/03/14 21.43 * ***************************************************************************** */ var nagt=navigator.useragent;if(!jquery.browser){jquery.browser={},jquery.browser.mozilla=!1,jquery.browser.webkit=!1,jquery.browser.opera=!1,jquery.browser.safari=!1,jquery.browser.chrome=!1,jquery.browser.msie=!1,jquery.browser.ua=nagt,jquery.browser.name=navigator.appname,jquery.browser.fullversion=""+parsefloat(navigator.appversion),jquery.browser.majorversion=parseint(navigator.appversion,10);var nameoffset,veroffset,ix;if(-1!=(veroffset=nagt.indexof("opera")))jquery.browser.opera=!0,jquery.browser.name="opera",jquery.browser.fullversion=nagt.substring(veroffset+6),-1!=(veroffset=nagt.indexof("version"))&&(jquery.browser.fullversion=nagt.substring(veroffset+8));else if(-1!=(veroffset=nagt.indexof("opr")))jquery.browser.opera=!0,jquery.browser.name="opera",jquery.browser.fullversion=nagt.substring(veroffset+4);else if(-1!=(veroffset=nagt.indexof("msie")))jquery.browser.msie=!0,jquery.browser.name="microsoft internet explorer",jquery.browser.fullversion=nagt.substring(veroffset+5);else if(-1!=nagt.indexof("trident")){jquery.browser.msie=!0,jquery.browser.name="microsoft internet explorer";var start=nagt.indexof("rv:")+3,end=start+4;jquery.browser.fullversion=nagt.substring(start,end)}else-1!=(veroffset=nagt.indexof("chrome"))?(jquery.browser.webkit=!0,jquery.browser.chrome=!0,jquery.browser.name="chrome",jquery.browser.fullversion=nagt.substring(veroffset+7)):-1!=(veroffset=nagt.indexof("safari"))?(jquery.browser.webkit=!0,jquery.browser.safari=!0,jquery.browser.name="safari",jquery.browser.fullversion=nagt.substring(veroffset+7),-1!=(veroffset=nagt.indexof("version"))&&(jquery.browser.fullversion=nagt.substring(veroffset+8))):-1!=(veroffset=nagt.indexof("applewebkit"))?(jquery.browser.webkit=!0,jquery.browser.name="safari",jquery.browser.fullversion=nagt.substring(veroffset+7),-1!=(veroffset=nagt.indexof("version"))&&(jquery.browser.fullversion=nagt.substring(veroffset+8))):-1!=(veroffset=nagt.indexof("firefox"))?(jquery.browser.mozilla=!0,jquery.browser.name="firefox",jquery.browser.fullversion=nagt.substring(veroffset+8)):(nameoffset=nagt.lastindexof(" ")+1)<(veroffset=nagt.lastindexof("/"))&&(jquery.browser.name=nagt.substring(nameoffset,veroffset),jquery.browser.fullversion=nagt.substring(veroffset+1),jquery.browser.name.tolowercase()==jquery.browser.name.touppercase()&&(jquery.browser.name=navigator.appname));-1!=(ix=jquery.browser.fullversion.indexof(";"))&&(jquery.browser.fullversion=jquery.browser.fullversion.substring(0,ix)),-1!=(ix=jquery.browser.fullversion.indexof(" "))&&(jquery.browser.fullversion=jquery.browser.fullversion.substring(0,ix)),jquery.browser.majorversion=parseint(""+jquery.browser.fullversion,10),isnan(jquery.browser.majorversion)&&(jquery.browser.fullversion=""+parsefloat(navigator.appversion),jquery.browser.majorversion=parseint(navigator.appversion,10)),jquery.browser.version=jquery.browser.majorversion}jquery.browser.android=/android/i.test(nagt),jquery.browser.blackberry=/blackberry|bb|playbook/i.test(nagt),jquery.browser.ios=/iphone|ipad|ipod|webos/i.test(nagt),jquery.browser.operamobile=/opera mini/i.test(nagt),jquery.browser.windowsmobile=/iemobile|windows phone/i.test(nagt),jquery.browser.kindle=/kindle|silk/i.test(nagt),jquery.browser.mobile=jquery.browser.android||jquery.browser.blackberry||jquery.browser.ios||jquery.browser.windowsmobile||jquery.browser.operamobile||jquery.browser.kindle,jquery.ismobile=jquery.browser.mobile,jquery.istablet=jquery.browser.mobile&&jquery(window).width()>765,jquery.isandroiddefault=jquery.browser.android&&!/chrome/i.test(nagt); ;/*___________________________________________________________________________________________________________________________________________________ _ jquery.mb.components _ _ _ _ file: jquery.mb.simpleslider.min.js _ _ last modified: 16/05/15 23.45 _ _ _ _ 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-2015. matteo bicocchi (pupunzi); _ ___________________________________________________________________________________________________________________________________________________*/ !function(a){/iphone|ipod|ipad|android|ie|blackberry|fennec/.test(navigator.useragent.tolowercase());var c="ontouchstart"in window||window.navigator&&window.navigator.mspointerenabled&&window.msgesture||window.documenttouch&&document instanceof documenttouch||!1;a.simpleslider={defaults:{initialval:0,scale:100,orientation:"h",readonly:!1,callback:!1},events:{start:c?"touchstart":"mousedown",end:c?"touchend":"mouseup",move:c?"touchmove":"mousemove"},init:function(b){return this.each(function(){var d=this,e=a(d);e.addclass("simpleslider"),d.opt={},a.extend(d.opt,a.simpleslider.defaults,b),a.extend(d.opt,e.data());var f="h"==d.opt.orientation?"horizontal":"vertical",g=a("").addclass("level").addclass(f);e.prepend(g),d.level=g,e.css({cursor:"default"}),"auto"==d.opt.scale&&(d.opt.scale=a(d).outerwidth()),e.updatesliderval(),d.opt.readonly||(e.on(a.simpleslider.events.start,function(a){c&&(a=a.changedtouches[0]),d.canslide=!0,e.updatesliderval(a),e.css({cursor:"col-resize"}),a.preventdefault(),a.stoppropagation()}),a(document).on(a.simpleslider.events.move,function(b){c&&(b=b.changedtouches[0]),d.canslide&&(a(document).css({cursor:"default"}),e.updatesliderval(b),b.preventdefault(),b.stoppropagation())}).on(a.simpleslider.events.end,function(){a(document).css({cursor:"auto"}),d.canslide=!1,e.css({cursor:"auto"})}))})},updatesliderval:function(b){function g(a,b){return math.floor(100*a/b)}var c=this,d=c.get(0);d.opt.initialval="number"==typeof d.opt.initialval?d.opt.initialval:d.opt.initialval(d);var e=a(d).outerwidth(),f=a(d).outerheight();d.x="object"==typeof b?b.clientx+document.body.scrollleft-c.offset().left:"number"==typeof b?b*e/d.opt.scale:d.opt.initialval*e/d.opt.scale,d.y="object"==typeof b?b.clienty+document.body.scrolltop-c.offset().top:"number"==typeof b?(d.opt.scale-d.opt.initialval-b)*f/d.opt.scale:d.opt.initialval*f/d.opt.scale,d.y=c.outerheight()-d.y,d.scalex=d.x*d.opt.scale/e,d.scaley=d.y*d.opt.scale/f,d.outofrangex=d.scalex>d.opt.scale?d.scalex-d.opt.scale:d.scalex<0?d.scalex:0,d.outofrangey=d.scaley>d.opt.scale?d.scaley-d.opt.scale:d.scaley<0?d.scaley:0,d.outofrange="h"==d.opt.orientation?d.outofrangex:d.outofrangey,d.value="undefined"!=typeof b?"h"==d.opt.orientation?d.x>=c.outerwidth()?d.opt.scale:d.x<=0?0:d.scalex:d.y>=c.outerheight()?d.opt.scale:d.y<=0?0:d.scaley:"h"==d.opt.orientation?d.scalex:d.scaley,"h"==d.opt.orientation?d.level.width(g(d.x,e)+"%"):d.level.height(g(d.y,f)),"function"==typeof d.opt.callback&&d.opt.callback(d)}},a.fn.simpleslider=a.simpleslider.init,a.fn.updatesliderval=a.simpleslider.updatesliderval}(jquery); ;/*___________________________________________________________________________________________________________________________________________________ _ jquery.mb.components _ _ _ _ file: jquery.mb.storage.min.js _ _ last modified: 24/05/15 16.08 _ _ _ _ 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-2015. matteo bicocchi (pupunzi); _ ___________________________________________________________________________________________________________________________________________________*/ !function(a){a.mbcookie={set:function(a,b,c,d){b=json.stringify(b),c||(c=7),d=d?"; domain="+d:"";var f,e=new date;e.settime(e.gettime()+1e3*60*60*24*c),f="; expires="+e.togmtstring(),document.cookie=a+"="+b+f+"; path=/"+d},get:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d