-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoogaloop.js
50 lines (44 loc) · 18.2 KB
/
moogaloop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
FILE ARCHIVED ON 4:44:34 Dec 27, 2014 AND RETRIEVED FROM THE
INTERNET ARCHIVE ON 13:22:24 Jul 27, 2016.
JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
SECTION 108(a)(3)).
*/
/* VimeoPlayer - v2.5.24 - 2014-12-10 */
(function(h,p,v){var r,s,t,D,E;(function(){(function(){for(var b=["webkit","moz"],a=0;a<b.length&&!h.requestAnimationFrame;++a){var c=b[a];h.requestAnimationFrame=h[c+"RequestAnimationFrame"];h.cancelAnimationFrame=h[c+"CancelAnimationFrame"]||h[c+"CancelRequestAnimationFrame"]}!/iP(ad|hone|od).*OS 6/.test(h.navigator.userAgent)&&h.requestAnimationFrame&&h.cancelAnimationFrame||(h.requestAnimationFrame=function(a){return setTimeout(a,0)},h.cancelAnimationFrame=clearTimeout)})();!Object.defineProperty&&
Object.prototype.__defineGetter__&&(Object.defineProperty=function(b,a,c){"get"in c&&b.__defineGetter__(a,c.get);"set"in c&&b.__defineSetter__(a,c.set);c.get||c.set||(b[a]=c.value)});!Object.defineProperties&&Object.defineProperty&&(Object.defineProperties=function(b,a){for(var c in a)try{Object.defineProperty(b,c,a[c])}catch(g){"'enumerable' attribute on the property descriptor cannot be set to 'true' on this object"===g.message&&(a[c].enumerable=!1,Object.defineProperty(b,c,a[c]))}return b});!Object.create&&
Object.defineProperty&&(Object.create=function(b,a){function c(){}if("object"!==typeof b&&"function"!==typeof b)throw new TypeError("Object prototype may only be an Object or null");c.prototype=b;var g=new c;g.__proto__=b;a!==v&&Object.defineProperties(g,a);return g});Object.keys||(Object.keys=function(b){if("object"!==typeof b&&"function"!==typeof b||null===b)throw new TypeError("Object.keys called on a non-object");var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a});Array.prototype.indexOf||
(Array.prototype.indexOf=function(b){for(var a=0,c=this.length;a<c;a++)if(a in this&&this[a]===b)return a;return-1});"classList"in p.documentElement||!Object.defineProperty||"undefined"===typeof HTMLElement||Object.defineProperty(HTMLElement.prototype,"classList",{get:function(){function b(c){return function(b){var e=a.className.split(/\s+/),d=e.indexOf(b);c(e,d,b);a.className=e.join(" ")}}var a=this,c={add:b(function(a,c,b){return~c||a.push(b)}),remove:b(function(a,c){return~c&&a.splice(c,1)}),toggle:b(function(a,
c,b){return~c?a.splice(c,1):a.push(b)}),contains:function(c){return!!~a.className.split(/\s+/).indexOf(c)},item:function(c){return a.className.split(/\s+/)[c]||null}};Object.defineProperty(c,"length",{get:function(){return a.className.split(/\s+/).length}});return c}})})();var w=function(){return function(b,a,c,g){var f=function(){return c.call(b,a)},e=function(a){return g.call(b,a)};if(Object.defineProperty){var d={enumerable:!0,get:f};g&&(d.set=e);try{Object.defineProperty(b,a,d)}catch(l){delete d.enumerable,
Object.defineProperty(b,a,d)}}else{var k=function(c){c.propertyName===a&&(b.detachEvent("onpropertychange",k),g&&e(b[a]),b[a]=f,b[a].toString=f,b.attachEvent("onpropertychange",k))};try{b[a]=f,b[a].toString=f}catch(h){}b.attachEvent("onpropertychange",k)}}}(),F=function(){return{make:function(b){b=b||{};var a={};b.on=function(c,g){c=[].concat(c);for(var f=0,e=c.length;f<e;f++){var d=c[f];d&&(a[d]||(a[d]=[]),a[d].push(g))}return b};b.once=function(a,g){function f(){g.apply(b.off(a,f),arguments)}f.handler=
g;return b.on(a,f)};b.off=function(c,g){c=[].concat(c);for(var f=0,e=c.length;f<e;f++){var d=c[f];if(d&&d in a){var l=a[d].indexOf(g);if(-1===l){for(var k=0,h=a[d].length;k<h;k++)if(a[d][k].handler===g){l=f;break}if(-1===l)break}a[d].splice(l,1)}}return b};b.fire=function(c){if(!c)return b;if(c in a)for(var g=a[c].slice(0),f=0,e=g.length;f<e;f++)g[f].apply(b,g.slice.call(arguments,1));return b};return b}}}(),m=function(b,a){return{addCssRule:function(a,g,f){try{f=f||b.styleSheets[0],f.addRule?f.addRule(a,
g):f.insertRule(a+"{"+g+"}",(f.cssRules||f.rules).length)}catch(e){}},attachClickHandler:function(c,g,f,e){var d=!1;e="function"===typeof g?f:e;f="function"===typeof g?g:f;g="function"===typeof g?null:g;var l=function(c){var g=!0;if(c.changedTouches){var u=b.elementFromPoint(c.changedTouches[0].pageX-a.pageXOffset,c.changedTouches[0].pageY-a.pageYOffset);null!==u&&this.contains(u)&&(g=f.call(this,c))}"function"===typeof e&&e.call(this,c);d=!0;return g},k=function(a){if(!d)return f.call(this,a);d=
!1};if(g)Gator(c).on("click",g,k).on("touchend",g,l);else Gator(c).on("click",k).on("touchend",l)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},limit:function(a,b,f){return a>f?f:b>a?b:a},openWindow:function(c,b,f,e,d){var l=(a.screenY||a.screenTop||0)+a.outerHeight/2-f/2,k=(a.screenX||a.screenLeft||0)+a.outerWidth/2-b/2;a.chrome&&-1!==a.navigator.userAgent.toLowerCase().indexOf("mac os x")&&(f+=27);a.safari&&(f+=47);return a.open(c,e,d+",width="+b+",height="+f+
",left="+k+",top="+l)},parseTime:function(a){var b=a.match(/t=([0-9hms:]+)/);null!==b&&(a=b[1]);var f=!1,e=0,d=0,l=0,k=0;(b=a.match(/^([0-9]+)$/))&&b.length&&(f=!0,k=b[1]);!1===f&&(b=a.match(/^(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?/),null!==b&&""!==b[0]&&(f=!0,d=b[2],l=b[4],k=b[6]));!1===f&&(b=a.match(/^([0-9:]+)/),null!==b&&(f=!0,a=a.split(":").reverse(),k=a[0],a[1]&&(l=a[1]),a[2]&&(d=a[2])));if(!f)return null;d&&(e+=3600*d);l&&(e+=60*l);k&&(e+=parseInt(k,10));return e},resetFocus:function(c){c=(c||
b).querySelectorAll("*[tabindex]");for(var g=[],f=0,e,d,l=0,k=c.length;l<k;l++)e=c[l],d=a.getComputedStyle(e,""),0<e.tabIndex&&"none"!==d.display&&0<d.opacity&&"hidden"!==d.visibility&&(g[f++]=e);if(c=g.shift())c.focus(),c.blur()},round:function(a,b){a=parseFloat(a);if(isNaN(a))return 0;var f=Math.pow(10,b||3);return Math.round(a*f)/f},throttle:function(a,b){var f,e,d,l,k=0,h=function(){k=new Date;d=null;l=a.apply(f,e)};return function(){var n=new Date,u=b-(n-k);f=this;e=arguments;0>=u?(clearTimeout(d),
d=null,k=n,l=a.apply(f,e)):d||(d=setTimeout(h,u));return l}}}}(p,h);D=2;E=4;s="willOpenVodPurchaseForm";r="willOpenLoginForm";t=6;var J=function(){return function(b,a){function c(){switch(b._video&&b._video.currentRenderer){case "html":return"HTML5";case "flash":return"Flideo";case "moogaloop":return"Moogaloop";default:return"Player"}}function g(a,c){0;h._gaq&&h._gaq.push(["player._trackSocial",a,c,b.video.share_url])}var f=b.request.session,e=!0;(function(){b.request.flags.dnt?0:(a.on(254,function(){g("Facebook",
"share")}),a.on(255,function(){g("Twitter","tweet")}),a.on(257,function(){g("Email","email")}))})();(function(){var d;a.on([57,105],function(a){d||(d=a||(new Date).getTime())});a.on(58,function(){if(0<d){var a=b._video.currentFile.quality,f="Buffer Time";e&&(e=!1,f="Start Time");var g=d,g=(new Date).getTime()-g;0;h._gaq&&h._gaq.push(["player._trackTiming",c(),f,g,a]);d=null}})})();(function(){function c(){try{h=new ns_.StreamingTag({customerC2:b.request.comscore_id}),g&&(f(),g=!1)}catch(a){}}function f(){try{h.playContentPart({ns_st_ci:b.video.id})}catch(a){}}
if(b.request.flags.dnt||!b.request.flags.plays)0;else{var e=p.getElementById("player-comscore"),g=!1,h;a.on(52,function(){if(!h){if("undefined"===typeof ns_){if(!e){e=p.createElement("script");e.id="player-comscore";e.async=!0;e.src=b.request.urls.comscore_js;var a=p.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}e.addEventListener("load",c,!1);g=!0;return}c()}f()});a.on(51,function(){try{h&&h.stop()}catch(a){}})}})();(function(){a.on(312,function(a){b=a;f!==a.request.session&&(h._gaq&&
h._gaq.push(["player._trackPageview","/video/"+b.video.id]),e=!0)})})();a.fire(358);return{}}}(),M=function(){return function(b,a,c){function g(){r in h[e+"_delegate"]||(h[e+"_delegate"][r]=function(a,b){d.fire(t,"login-"+b);return!1});s in h[e+"_delegate"]||(h[e+"_delegate"][s]=function(a,b){d.fire(t,"purchase",{productId:b});return!1})}function f(){if(!b.api_addEventListener)return setTimeout(f,50);b.api_addEventListener("loadProgress",e+"_onLoadProgress");b.api_addEventListener("playProgress",
e+"_onPlayProgress");b.api_addEventListener("play",e+"_onPlay");b.api_addEventListener("pause",e+"_onPause");b.api_addEventListener("finish",e+"_onFinish");b.api_addEventListener("seek",e+"_onSeek");b.api_addEventListener("volumeChange",e+"_onVolumeChange");b.api_addEventListener("_trackEvent",e+"_trackEvent");b.api_addEventListener("_trackSocial",e+"_trackSocial");b.api_addEventListener("_trackTiming",e+"_trackTiming");b.api_setDelegate&&b.api_setDelegate(e+"_delegate");var c=m.parseTime(p.location.hash);
if(null!==c){c=m.limit(c,0,a.video.duration);a.embed.time=c;a.embed.autoplay=1;b&&b.api_seekTo&&b.api_seekTo(c);try{-1<p.location.hash.indexOf("at=")&&history&&history.replaceState&&history.replaceState("",p.title,h.location.pathname)}catch(d){}}}var e="moogaloop_"+Math.round(1E3*Math.random()+(new Date).getTime());a._video={};a._video.currentTime=0;a._video.paused=!0;a._video.currentRenderer="moogaloop";a._video.currentFile={quality:"unknown"};var d=F.make(),l=new K(a,d);L(a,d);h[e+"_delegate"]=
c||{};(function(){d.on(102,function(){b.api_play()});d.on(101,function(){b.api_pause()});d.on(2,function(a){b.api_loadVideo(a)});d.on(7,function(){b.api_unload()});d.on(319,function(a,c){b.api_setEmbedSetting&&b.api_setEmbedSetting(a,c)})})();(function(){d.on(11,function(c){c=c.replace("#","");a.embed.color=c;b.api_changeColor(c)});d.on(1,function(a,c){b.api_seekTo(c)});d.on(8,function(c){b.api_loop(c);a.embed.loop=!!c});d.on(3,function(a){b.api_setVolume(a)})})();(function(){h[e+"_onLoadProgress"]=
function(a){d.fire(53,a.duration*a.percent,a.duration,a.percent)};h[e+"_onPlayProgress"]=function(b){a._video.currentTime=b.duration*b.percent;d.fire(54,a._video.currentTime,b.duration,b.percent)};h[e+"_onPlay"]=function(b){a._video.paused=!1;d.fire(52)};h[e+"_onPause"]=function(b){a._video.paused=!0;d.fire(51)};h[e+"_onFinish"]=function(b){a._video.paused=!0;d.fire(56)};h[e+"_onSeek"]=function(a){d.fire(55,a.seconds,a.duration,a.percent)};h[e+"_onVolumeChange"]=function(b){a.request.cookie.volume=
b;d.fire(59,b)}})();(function(){J(a,d);var b={Facebook:254,Twitter:255,Tumblr:256,Email:257};h[e+"_trackSocial"]=function(a){a.network in b&&(a=[].concat(b[a.network]),d.fire.apply(null,a))};h[e+"_trackTiming"]=function(b){a._video.currentFile.quality=b.quality;d.fire(57,b.time);d.fire(58)}})();g();(function(){d.on(307,function(a){b.api_setLoggedIn&&b.api_setLoggedIn(!0,a)})})();d.fire(359);f();var k={};try{Object.defineProperty({},"fakeprop",{})}catch(v){k=p.createElement("vimeo"),p.body.appendChild(k)}w(k,
"config",function(){return a},function(b){a=b;d.fire(312,a)});w(k,"delegate",null,function(a){h[e+"_delegate"]=a;g()});k.ready=function(a){if("function"!==typeof a)throw new TypeError("You can only pass a function to ready().");a.call(k)};for(var n in l)l.hasOwnProperty(n)&&("function"===typeof l[n]?k[n]=l[n]:w(k,n,l[n].get,l[n].set||!1));Object.preventExtensions&&Object.preventExtensions(k);return k}}(),K=function(b){return function(a,c){function g(a,b){this.message=b;try{d({event:"error",data:{message:b,
code:a}})}catch(c){}}function f(){if(a.view===D)throw new g("private_video","The video is private.");if(a.view===E)throw new g("password_video","The video is password-protected. The viewer must enter the password first.");}function e(a){if(a&&""!==a){if("object"===typeof a)return a;try{return JSON.parse(a)}catch(b){var c={};a.split("&").forEach(function(a){try{var b=a.split("="),y=decodeURIComponent(b[0]),d=decodeURIComponent(b[1]);"id"!==y&&("params"===y&&(y="value"),d=d.split(",")[0],c[y]=d)}catch(e){}});
return c}}}function d(c){if(c.event&&(s.fire(c.event,c.data),!r[c.event]))return;if(w){var d="";a.embed.player_id&&(c.player_id=a.embed.player_id);if(1===a.embed.api){d=c.event;if(1===a.embed.api){for(var e in z)if(z[e]===c.event){d=e;break}switch(d){case "onSeek":case "onProgress":delete c.data.percent;delete c.data.duration;break;case "onLoading":delete c.data.seconds,delete c.data.duration}}e="method="+encodeURIComponent(d||c.method);e+="¶ms=";d=[];if(c.value!==v)d.push(encodeURIComponent(c.value));
else if("object"===typeof c.data)for(var f in c.data)d.push(encodeURIComponent(c.data[f]));else c.data!==v&&d.push(encodeURIComponent(c.data));c.player_id&&d.push(c.player_id);d=e+=d.join(",")}else try{d=JSON.stringify(c)}catch(g){}0;if(b.parent!=b)try{b.parent.postMessage(d,n)}catch(h){}}}function h(b){if(b&&"_"!==b.substr(0,1)){1===a.embed.api&&(b=b.replace("api_",""));switch(b){case "changeColor":return q.color.set;case "paused":return q.paused.get;case "seekTo":return q.currentTime.set}if("function"===
typeof q[b])return q[b];var c=b.substr(0,3);b=b.substr(3,1).toLowerCase()+b.substr(4);return q[b]&&q[b][c]?q[b][c]:!1}}function k(a){if(0===(p.referrer||b.location.origin||b.location.href).indexOf(a.origin)){var c=e(a.data),f=c.method,c=c.value,g=h(f);g&&(0,a=g.call(a,c),a!==v&&""!==a&&d({method:f,value:a}))}}function t(){if(G&&x){try{switch(x){case "not-supported":throw new g("not_supported","This video is not supported in this browser.");case "no-files":throw new g("file_error","There was an error loading the files for this video.");
default:throw new g("playback","An error occurred during playback.");}}catch(a){}x=null}}var n=p.referrer||a.request.referrer;try{n=decodeURIComponent(n)}catch(u){n=unescape(n)}var r={ready:!0,error:!0},s=F.make({}),w=!(!b.postMessage||!b.parent.postMessage),B=null,G=!1,A=!1,x=null,C=!1,H,I="play pause finish playProgress loadProgress seek cuechange".split(" "),z={onFinish:"finish",onLoading:"loadProgress",onLoad:"ready",onProgress:"playProgress",onPlay:"play",onPause:"pause",onSeek:"seek"};g.prototype=
Error();var q={addEventListener:function(a,b){a in z&&(a=z[a]);if(0>I.indexOf(a))throw new g("invalid_event",'"'+a+'" is not a valid event. Valid events are: '+I.join(", ")+".");if(b)s.on(a,b);else r[a]=!0;0},removeEventListener:function(a,b){b?s.off(a,b):r[a]=!1;0},play:function(){f();if("[object MessageEvent]"===Object.prototype.toString.call(this)&&"undefined"!==typeof Support&&(Support.iPhone||Support.iPad||Support.iPod)&&!C)throw new g("play","The viewer must initiate playback first.");c.fire(102,
!0)},pause:function(){f();c.fire(101)},loadVideo:function(b){if(!a.embed.on_site&&isNaN(b))throw new g("invalid_video","The video id must be a number.");c.fire(2,b)},unload:function(){1!==a.view&&3!==a.view||c.fire(7)},_setEmbedSetting:function(b,d){a.embed.on_site&&(b in a.embed.settings||"custom_logo"===b)&&(d="object"===typeof d?d:Number(d),"badge"===b&&(d?d=H:H=a.embed.settings.badge),a.embed.settings[b]=d,c.fire(319,b,d),c.fire(312,a))},color:{get:function(){return a.embed.color.replace("#",
"")},set:function(b){if(a.embed.settings.color&&!a.embed.on_site)throw new g("color_locked","The creator of the video has chosen to always use "+(new Color(a.embed.color)).hex+".");b=(b+"").replace("#","");if("string"!==typeof b||3!==b.length&&6!==b.length||isNaN(parseInt(b,16)))throw new g("invalid_color","The color should be 3- or 6-digit hex value.");if("undefined"===typeof Color||"implement"in Color)c.fire(11,b);else try{var d=new Color(b);c.fire(11,d);if(3>(new Color(23,35,34,0.75)).contrast(d).ratio)throw new g("color_contrast",
"Specified color does not meet minimum contrast ratio. We recommend using brighter colors. See WCAG 2.0 guidelines: /web/20141227044434/http://www.w3.org/TR/WCAG/#visual-audio-contrast");}catch(e){}}},currentTime:{get:function(){return a._video&&0.1<a._video.currentTime?m.round(a._video.currentTime):0},set:function(b){b=parseFloat(b);if(isNaN(b)||0>b||b>a.video.duration)throw new g("invalid_time","Seconds must be a positive float less than the duration of the video ("+a.video.duration+").");c.fire(1,null,b);c.fire(301)}},
duration:{get:function(){return m.round(a.video.duration)}},loop:{get:function(){return!!a.embed.loop},set:function(a){c.fire(8,a)}},paused:{get:function(){return a._video&&"paused"in a._video?!!a._video.paused:!0}},videoEmbedCode:{get:function(){return a.video.embed_code}},videoHeight:{get:function(){return a.video.video_height||a.video.height}},videoId:{get:function(){return a.video.id}},videoTitle:{get:function(){return a.video.title}},videoWidth:{get:function(){return a.video.video_width||a.video.width}},
videoUrl:{get:function(){return a.video.url}},volume:{get:function(){var b=m.round(a.request.cookie.volume);return 1===a.embed.api?Math.round(100*b):b},set:function(b){b=parseFloat(b);1===a.embed.api&&(b/=100);if(isNaN(b)||0>b||1<b)throw new g("invalid_volume","Volume should be a float between 0 and 1.");B=b;c.fire(3,b,!0)}}};c.on(50,function(){C=!0});b.addEventListener?b.addEventListener("message",k,!1):b.attachEvent("onmessage",k);(function(){c.on(52,function(){A||(A=!0,d({event:"play"}))});c.on(51,
function(){A=!1;d({event:"pause"})});c.on(56,function(){A=!1;d({event:"finish"})});c.on(54,function(a,b,c){d({event:"playProgress",data:{seconds:m.round(a),percent:m.round(c),duration:m.round(b)}})});c.on(53,function(a,b,c){d({event:"loadProgress",data:{bytesLoaded:-1,bytesTotal:-1,percent:m.round(c),duration:m.round(b),seconds:m.round(a)}})});c.on(55,function(a,b,c){d({event:"seek",data:{seconds:m.round(a),percent:m.round(c),duration:m.round(b)}})});c.on(49,function(a){x=a;t()});c.on(62,function(a,
b){var c=null,e=null;a&&(e=a.split("."),c=e[0],e=e[1]);d({event:"cuechange",data:{language:c,kind:e,cues:b}})})})();(function(){c.on(7,function(){x=null;C=!1})})();(function(){c.on(312,function(b){a=b;B&&setTimeout(function(){0;c.fire(3,B,!0)},0)})})();c.fire(357);c.on(359,function(){G=!0;d({event:"ready"});t()});return q}}(this),L=function(){return function(b,a){var c=null;(function(){a.on(t,function(g,f){var e="//"+b.player_url,d=e+"/video/"+b.video.id,h=670,k=545;switch(g){case "login-like":c=
m.openWindow(d+"/login/like",h,k,"login");a.fire(259,g);break;case "login-watch-later":c=m.openWindow(d+"/login/watch-later",h,k,"login");a.fire(259,g);break;case "login-private-locked":c=m.openWindow(d+"/login/private",h,k,"login");a.fire(259,g);break;case "purchase":e=e+"/video/"+(b.video.vod.feature_id||b.video.id)+"/purchase/vod",h=790,k=670,f&&f.productId&&(e+="/"+f.productId),e+="?referrer="+encodeURIComponent(b.request.referrer),c=m.openWindow(e,h,k,"purchase"),a.fire(259,g)}});h.closePopup=
function(){if(c){try{c.close()}catch(a){}c=null}}})();(function(){b.embed.on_site||(h.confirmPurchase=function(b,c,e){if(c)return a.fire(2,b);e&&a.fire(102)})})();(function(){b.embed.on_site||(h.confirmLoginAction=function(b,c){a.fire(307,c)})})();return{}}}();h.VimeoPlayer=M})(window,document);