popcornjs-rails 1.3.0 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,160 +1,209 @@
1
1
  /*
2
- * popcorn.js version 1.3
2
+ * popcorn.js version 1.5.6
3
3
  * http://popcornjs.org
4
4
  *
5
5
  * Copyright 2011, Mozilla Foundation
6
6
  * Licensed under the MIT license
7
7
  */
8
8
 
9
- (function(r,f){function n(a,g){return function(){if(d.plugin.debug)return a.apply(this,arguments);try{return a.apply(this,arguments)}catch(l){d.plugin.errors.push({plugin:g,thrown:l,source:a.toString()});this.emit("pluginerror",d.plugin.errors)}}}if(f.addEventListener){var c=Array.prototype,b=Object.prototype,e=c.forEach,h=c.slice,i=b.hasOwnProperty,j=b.toString,p=r.Popcorn,m=[],o=false,q={events:{hash:{},apis:{}}},s=function(){return r.requestAnimationFrame||r.webkitRequestAnimationFrame||r.mozRequestAnimationFrame||
10
- r.oRequestAnimationFrame||r.msRequestAnimationFrame||function(a){r.setTimeout(a,16)}}(),d=function(a,g){return new d.p.init(a,g||null)};d.version="1.3";d.isSupported=true;d.instances=[];d.p=d.prototype={init:function(a,g){var l,k=this;if(typeof a==="function")if(f.readyState==="complete")a(f,d);else{m.push(a);if(!o){o=true;var t=function(){f.removeEventListener("DOMContentLoaded",t,false);for(var z=0,C=m.length;z<C;z++)m[z].call(f,d);m=null};f.addEventListener("DOMContentLoaded",t,false)}}else{if(typeof a===
11
- "string")try{l=f.querySelector(a)}catch(u){throw Error("Popcorn.js Error: Invalid media element selector: "+a);}this.media=l||a;l=this.media.nodeName&&this.media.nodeName.toLowerCase()||"video";this[l]=this.media;this.options=g||{};this.id=this.options.id||d.guid(l);if(d.byId(this.id))throw Error("Popcorn.js Error: Cannot use duplicate ID ("+this.id+")");this.isDestroyed=false;this.data={running:{cue:[]},timeUpdate:d.nop,disabled:{},events:{},hooks:{},history:[],state:{volume:this.media.volume},trackRefs:{},
12
- trackEvents:{byStart:[{start:-1,end:-1}],byEnd:[{start:-1,end:-1}],animating:[],startIndex:0,endIndex:0,previousUpdateTime:-1}};d.instances.push(this);var v=function(){if(k.media.currentTime<0)k.media.currentTime=0;k.media.removeEventListener("loadeddata",v,false);var z,C,E,B,w;z=k.media.duration;z=z!=z?Number.MAX_VALUE:z+1;d.addTrackEvent(k,{start:z,end:z});if(k.options.frameAnimation){k.data.timeUpdate=function(){d.timeUpdate(k,{});d.forEach(d.manifest,function(D,F){if(C=k.data.running[F]){B=C.length;
13
- for(var I=0;I<B;I++){E=C[I];(w=E._natives)&&w.frame&&w.frame.call(k,{},E,k.currentTime())}}});k.emit("timeupdate");!k.isDestroyed&&s(k.data.timeUpdate)};!k.isDestroyed&&s(k.data.timeUpdate)}else{k.data.timeUpdate=function(D){d.timeUpdate(k,D)};k.isDestroyed||k.media.addEventListener("timeupdate",k.data.timeUpdate,false)}};Object.defineProperty(this,"error",{get:function(){return k.media.error}});k.media.readyState>=2?v():k.media.addEventListener("loadeddata",v,false);return this}}};d.p.init.prototype=
14
- d.p;d.byId=function(a){for(var g=d.instances,l=g.length,k=0;k<l;k++)if(g[k].id===a)return g[k];return null};d.forEach=function(a,g,l){if(!a||!g)return{};l=l||this;var k,t;if(e&&a.forEach===e)return a.forEach(g,l);if(j.call(a)==="[object NodeList]"){k=0;for(t=a.length;k<t;k++)g.call(l,a[k],k,a);return a}for(k in a)i.call(a,k)&&g.call(l,a[k],k,a);return a};d.extend=function(a){var g=h.call(arguments,1);d.forEach(g,function(l){for(var k in l)a[k]=l[k]});return a};d.extend(d,{noConflict:function(a){if(a)r.Popcorn=
15
- p;return d},error:function(a){throw Error(a);},guid:function(a){d.guid.counter++;return(a?a:"")+(+new Date+d.guid.counter)},sizeOf:function(a){var g=0,l;for(l in a)g++;return g},isArray:Array.isArray||function(a){return j.call(a)==="[object Array]"},nop:function(){},position:function(a){a=a.getBoundingClientRect();var g={},l=f.documentElement,k=f.body,t,u,v;t=l.clientTop||k.clientTop||0;u=l.clientLeft||k.clientLeft||0;v=r.pageYOffset&&l.scrollTop||k.scrollTop;l=r.pageXOffset&&l.scrollLeft||k.scrollLeft;
16
- t=Math.ceil(a.top+v-t);u=Math.ceil(a.left+l-u);for(var z in a)g[z]=Math.round(a[z]);return d.extend({},g,{top:t,left:u})},disable:function(a,g){if(!a.data.disabled[g]){a.data.disabled[g]=true;for(var l=a.data.running[g].length-1,k;l>=0;l--){k=a.data.running[g][l];k._natives.end.call(a,null,k)}}return a},enable:function(a,g){if(a.data.disabled[g]){a.data.disabled[g]=false;for(var l=a.data.running[g].length-1,k;l>=0;l--){k=a.data.running[g][l];k._natives.start.call(a,null,k)}}return a},destroy:function(a){var g=
17
- a.data.events,l=a.data.trackEvents,k,t,u,v;for(t in g){k=g[t];for(u in k)delete k[u];g[t]=null}for(v in d.registryByName)d.removePlugin(a,v);l.byStart.length=0;l.byEnd.length=0;if(!a.isDestroyed){a.data.timeUpdate&&a.media.removeEventListener("timeupdate",a.data.timeUpdate,false);a.isDestroyed=true}}});d.guid.counter=1;d.extend(d.p,function(){var a={};d.forEach("load play pause currentTime playbackRate volume duration preload playbackRate autoplay loop controls muted buffered readyState seeking paused played seekable ended".split(/\s+/g),
18
- function(g){a[g]=function(l){var k;if(typeof this.media[g]==="function"){if(l!=null&&/play|pause/.test(g))this.media.currentTime=d.util.toSeconds(l);this.media[g]();return this}if(l!=null){k=this.media[g];this.media[g]=l;k!==l&&this.emit("attrchange",{attribute:g,previousValue:k,currentValue:l});return this}return this.media[g]}});return a}());d.forEach("enable disable".split(" "),function(a){d.p[a]=function(g){return d[a](this,g)}});d.extend(d.p,{roundTime:function(){return Math.round(this.media.currentTime)},
19
- exec:function(a,g,l){var k=arguments.length,t,u;try{u=d.util.toSeconds(a)}catch(v){}if(typeof u==="number")a=u;if(typeof a==="number"&&k===2){l=g;g=a;a=d.guid("cue")}else if(k===1)g=-1;else if(t=this.getTrackEvent(a)){if(typeof a==="string"&&k===2){if(typeof g==="number")l=t._natives.start;if(typeof g==="function"){l=g;g=t.start}}}else if(k>=2){if(typeof g==="string"){try{u=d.util.toSeconds(g)}catch(z){}g=u}if(typeof g==="number")l=d.nop();if(typeof g==="function"){l=g;g=-1}}d.addTrackEvent(this,
20
- {id:a,start:g,end:g+1,_running:false,_natives:{start:l||d.nop,end:d.nop,type:"cue"}});return this},mute:function(a){a=a==null||a===true?"muted":"unmuted";if(a==="unmuted"){this.media.muted=false;this.media.volume=this.data.state.volume}if(a==="muted"){this.data.state.volume=this.media.volume;this.media.muted=true}this.emit(a);return this},unmute:function(a){return this.mute(a==null?false:!a)},position:function(){return d.position(this.media)},toggle:function(a){return d[this.data.disabled[a]?"enable":
21
- "disable"](this,a)},defaults:function(a,g){if(d.isArray(a)){d.forEach(a,function(l){for(var k in l)this.defaults(k,l[k])},this);return this}if(!this.options.defaults)this.options.defaults={};this.options.defaults[a]||(this.options.defaults[a]={});d.extend(this.options.defaults[a],g);return this}});d.Events={UIEvents:"blur focus focusin focusout load resize scroll unload",MouseEvents:"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave click dblclick",Events:"loadstart progress suspend emptied stalled play pause error loadedmetadata loadeddata waiting playing canplay canplaythrough seeking seeked timeupdate ended ratechange durationchange volumechange"};
22
- d.Events.Natives=d.Events.UIEvents+" "+d.Events.MouseEvents+" "+d.Events.Events;q.events.apiTypes=["UIEvents","MouseEvents","Events"];(function(a,g){for(var l=q.events.apiTypes,k=a.Natives.split(/\s+/g),t=0,u=k.length;t<u;t++)g.hash[k[t]]=true;l.forEach(function(v){g.apis[v]={};for(var z=a[v].split(/\s+/g),C=z.length,E=0;E<C;E++)g.apis[v][z[E]]=true})})(d.Events,q.events);d.events={isNative:function(a){return!!q.events.hash[a]},getInterface:function(a){if(!d.events.isNative(a))return false;var g=
23
- q.events,l=g.apiTypes;g=g.apis;for(var k=0,t=l.length,u,v;k<t;k++){v=l[k];if(g[v][a]){u=v;break}}return u},all:d.Events.Natives.split(/\s+/g),fn:{trigger:function(a,g){var l;if(this.data.events[a]&&d.sizeOf(this.data.events[a])){if(l=d.events.getInterface(a)){l=f.createEvent(l);l.initEvent(a,true,true,r,1);this.media.dispatchEvent(l);return this}d.forEach(this.data.events[a],function(k){k.call(this,g)},this)}return this},listen:function(a,g){var l=this,k=true,t=d.events.hooks[a],u;if(!this.data.events[a]){this.data.events[a]=
24
- {};k=false}if(t){t.add&&t.add.call(this,{},g);if(t.bind)a=t.bind;if(t.handler){u=g;g=function(v){t.handler.call(l,v,u)}}k=true;if(!this.data.events[a]){this.data.events[a]={};k=false}}this.data.events[a][g.name||g.toString()+d.guid()]=g;!k&&d.events.all.indexOf(a)>-1&&this.media.addEventListener(a,function(v){d.forEach(l.data.events[a],function(z){typeof z==="function"&&z.call(l,v)})},false);return this},unlisten:function(a,g){if(this.data.events[a]&&this.data.events[a][g]){delete this.data.events[a][g];
25
- return this}this.data.events[a]=null;return this}},hooks:{canplayall:{bind:"canplaythrough",add:function(a,g){var l=false;if(this.media.readyState){g.call(this,a);l=true}this.data.hooks.canplayall={fired:l}},handler:function(a,g){if(!this.data.hooks.canplayall.fired){g.call(this,a);this.data.hooks.canplayall.fired=true}}}}};d.forEach([["trigger","emit"],["listen","on"],["unlisten","off"]],function(a){d.p[a[0]]=d.p[a[1]]=d.events.fn[a[0]]});d.addTrackEvent=function(a,g){var l,k;if(g.id)l=a.getTrackEvent(g.id);
26
- if(l){k=true;g=d.extend({},l,g);a.removeTrackEvent(g.id)}if(g&&g._natives&&g._natives.type&&a.options.defaults&&a.options.defaults[g._natives.type])g=d.extend({},a.options.defaults[g._natives.type],g);if(g._natives){g._id=g.id||g._id||d.guid(g._natives.type);a.data.history.push(g._id)}g.start=d.util.toSeconds(g.start,a.options.framerate);g.end=d.util.toSeconds(g.end,a.options.framerate);var t=a.data.trackEvents.byStart,u=a.data.trackEvents.byEnd,v;for(v=t.length-1;v>=0;v--)if(g.start>=t[v].start){t.splice(v+
27
- 1,0,g);break}for(t=u.length-1;t>=0;t--)if(g.end>u[t].end){u.splice(t+1,0,g);break}if(g.end>a.media.currentTime&&g.start<=a.media.currentTime){g._running=true;a.data.running[g._natives.type].push(g);a.data.disabled[g._natives.type]||g._natives.start.call(a,null,g)}v<=a.data.trackEvents.startIndex&&g.start<=a.data.trackEvents.previousUpdateTime&&a.data.trackEvents.startIndex++;t<=a.data.trackEvents.endIndex&&g.end<a.data.trackEvents.previousUpdateTime&&a.data.trackEvents.endIndex++;this.timeUpdate(a,
28
- null,true);g._id&&d.addTrackEvent.ref(a,g);if(k){k=g._natives.type==="cue"?"cuechange":"trackchange";a.emit(k,{id:g.id,previousValue:{time:l.start,fn:l._natives.start},currentValue:{time:g.start,fn:g._natives.start}})}};d.addTrackEvent.ref=function(a,g){a.data.trackRefs[g._id]=g;return a};d.removeTrackEvent=function(a,g){for(var l,k,t=a.data.history.length,u=a.data.trackEvents.byStart.length,v=0,z=0,C=[],E=[],B=[],w=[];--u>-1;){l=a.data.trackEvents.byStart[v];k=a.data.trackEvents.byEnd[v];if(!l._id){C.push(l);
29
- E.push(k)}if(l._id){l._id!==g&&C.push(l);k._id!==g&&E.push(k);if(l._id===g){z=v;l._natives._teardown&&l._natives._teardown.call(a,l)}}v++}u=a.data.trackEvents.animating.length;v=0;if(u)for(;--u>-1;){l=a.data.trackEvents.animating[v];l._id||B.push(l);l._id&&l._id!==g&&B.push(l);v++}z<=a.data.trackEvents.startIndex&&a.data.trackEvents.startIndex--;z<=a.data.trackEvents.endIndex&&a.data.trackEvents.endIndex--;a.data.trackEvents.byStart=C;a.data.trackEvents.byEnd=E;a.data.trackEvents.animating=B;for(u=
30
- 0;u<t;u++)a.data.history[u]!==g&&w.push(a.data.history[u]);a.data.history=w;d.removeTrackEvent.ref(a,g)};d.removeTrackEvent.ref=function(a,g){delete a.data.trackRefs[g];return a};d.getTrackEvents=function(a){var g=[];a=a.data.trackEvents.byStart;for(var l=a.length,k=0,t;k<l;k++){t=a[k];t._id&&g.push(t)}return g};d.getTrackEvents.ref=function(a){return a.data.trackRefs};d.getTrackEvent=function(a,g){return a.data.trackRefs[g]};d.getTrackEvent.ref=function(a,g){return a.data.trackRefs[g]};d.getLastTrackEventId=
31
- function(a){return a.data.history[a.data.history.length-1]};d.timeUpdate=function(a,g){var l=a.media.currentTime,k=a.data.trackEvents.previousUpdateTime,t=a.data.trackEvents,u=t.endIndex,v=t.startIndex,z=t.byStart.length,C=t.byEnd.length,E=d.registryByName,B,w,D;if(k<=l){for(;t.byEnd[u]&&t.byEnd[u].end<=l;){B=t.byEnd[u];w=(k=B._natives)&&k.type;if(!k||E[w]||a[w]){if(B._running===true){B._running=false;D=a.data.running[w];D.splice(D.indexOf(B),1);if(!a.data.disabled[w]){k.end.call(a,g,B);a.emit("trackend",
32
- d.extend({},B,{plugin:w,type:"trackend"}))}}u++}else{d.removeTrackEvent(a,B._id);return}}for(;t.byStart[v]&&t.byStart[v].start<=l;){B=t.byStart[v];w=(k=B._natives)&&k.type;if(!k||E[w]||a[w]){if(B.end>l&&B._running===false){B._running=true;a.data.running[w].push(B);if(!a.data.disabled[w]){k.start.call(a,g,B);a.emit("trackstart",d.extend({},B,{plugin:w,type:"trackstart"}))}}v++}else{d.removeTrackEvent(a,B._id);return}}}else if(k>l){for(;t.byStart[v]&&t.byStart[v].start>l;){B=t.byStart[v];w=(k=B._natives)&&
33
- k.type;if(!k||E[w]||a[w]){if(B._running===true){B._running=false;D=a.data.running[w];D.splice(D.indexOf(B),1);if(!a.data.disabled[w]){k.end.call(a,g,B);a.emit("trackend",d.extend({},B,{plugin:w,type:"trackend"}))}}v--}else{d.removeTrackEvent(a,B._id);return}}for(;t.byEnd[u]&&t.byEnd[u].end>l;){B=t.byEnd[u];w=(k=B._natives)&&k.type;if(!k||E[w]||a[w]){if(B.start<=l&&B._running===false){B._running=true;a.data.running[w].push(B);if(!a.data.disabled[w]){k.start.call(a,g,B);a.emit("trackstart",d.extend({},
34
- B,{plugin:w,type:"trackstart"}))}}u--}else{d.removeTrackEvent(a,B._id);return}}}t.endIndex=u;t.startIndex=v;t.previousUpdateTime=l;t.byStart.length<z&&t.startIndex--;t.byEnd.length<C&&t.endIndex--};d.extend(d.p,{getTrackEvents:function(){return d.getTrackEvents.call(null,this)},getTrackEvent:function(a){return d.getTrackEvent.call(null,this,a)},getLastTrackEventId:function(){return d.getLastTrackEventId.call(null,this)},removeTrackEvent:function(a){d.removeTrackEvent.call(null,this,a);return this},
35
- removePlugin:function(a){d.removePlugin.call(null,this,a);return this},timeUpdate:function(a){d.timeUpdate.call(null,this,a);return this},destroy:function(){d.destroy.call(null,this);return this}});d.manifest={};d.registry=[];d.registryByName={};d.plugin=function(a,g,l){if(d.protect.natives.indexOf(a.toLowerCase())>=0)d.error("'"+a+"' is a protected function name");else{var k=["start","end"],t={},u=typeof g==="function",v=["_setup","_teardown","start","end","frame"],z=function(B,w){B=B||d.nop;w=w||
36
- d.nop;return function(){B.apply(this,arguments);w.apply(this,arguments)}};d.manifest[a]=l=l||g.manifest||{};v.forEach(function(B){g[B]=n(g[B]||d.nop,a)});var C=function(B,w){if(!w)return this;if(w.ranges&&d.isArray(w.ranges)){d.forEach(w.ranges,function(G){G=d.extend({},w,G);delete G.ranges;this[a](G)},this);return this}var D=w._natives={},F="",I;d.extend(D,B);w._natives.type=a;w._running=false;D.start=D.start||D["in"];D.end=D.end||D.out;if(w.once)D.end=z(D.end,function(){this.removeTrackEvent(w._id)});
37
- D._teardown=z(function(){var G=h.call(arguments),H=this.data.running[D.type];G.unshift(null);G[1]._running&&H.splice(H.indexOf(w),1)&&D.end.apply(this,G)},D._teardown);w.compose=w.compose&&w.compose.split(" ")||[];w.effect=w.effect&&w.effect.split(" ")||[];w.compose=w.compose.concat(w.effect);w.compose.forEach(function(G){F=d.compositions[G]||{};v.forEach(function(H){D[H]=z(D[H],F[H])})});w._natives.manifest=l;if(!("start"in w))w.start=w["in"]||0;if(!w.end&&w.end!==0)w.end=w.out||Number.MAX_VALUE;
38
- if(!i.call(w,"toString"))w.toString=function(){var G=["start: "+w.start,"end: "+w.end,"id: "+(w.id||w._id)];w.target!=null&&G.push("target: "+w.target);return a+" ( "+G.join(", ")+" )"};if(!w.target){I="options"in l&&l.options;w.target=I&&"target"in I&&I.target}if(w._natives)w._id=d.guid(w._natives.type);w._natives._setup&&w._natives._setup.call(this,w);d.addTrackEvent(this,w);d.forEach(B,function(G,H){H!=="type"&&k.indexOf(H)===-1&&this.on(H,G)},this);return this};d.p[a]=t[a]=function(B,w){var D;
39
- if(B&&!w)w=B;else if(D=this.getTrackEvent(B)){w=d.extend({},D,w);d.addTrackEvent(this,w);return this}else w.id=B;this.data.running[a]=this.data.running[a]||[];D=d.extend({},this.options.defaults&&this.options.defaults[a]||{},w);return C.call(this,u?g.call(this,D):g,D)};l&&d.extend(g,{manifest:l});var E={fn:t[a],definition:g,base:g,parents:[],name:a};d.registry.push(d.extend(t,E,{type:a}));d.registryByName[a]=E;return t}};d.plugin.errors=[];d.plugin.debug=d.version==="1.3";d.removePlugin=function(a,
40
- g){if(!g){g=a;a=d.p;if(d.protect.natives.indexOf(g.toLowerCase())>=0){d.error("'"+g+"' is a protected function name");return}var l=d.registry.length,k;for(k=0;k<l;k++)if(d.registry[k].name===g){d.registry.splice(k,1);delete d.registryByName[g];delete d.manifest[g];delete a[g];return}}l=a.data.trackEvents.byStart;k=a.data.trackEvents.byEnd;var t=a.data.trackEvents.animating,u,v;u=0;for(v=l.length;u<v;u++){if(l[u]&&l[u]._natives&&l[u]._natives.type===g){l[u]._natives._teardown&&l[u]._natives._teardown.call(a,
41
- l[u]);l.splice(u,1);u--;v--;if(a.data.trackEvents.startIndex<=u){a.data.trackEvents.startIndex--;a.data.trackEvents.endIndex--}}k[u]&&k[u]._natives&&k[u]._natives.type===g&&k.splice(u,1)}u=0;for(v=t.length;u<v;u++)if(t[u]&&t[u]._natives&&t[u]._natives.type===g){t.splice(u,1);u--;v--}};d.compositions={};d.compose=function(a,g,l){d.manifest[a]=l||g.manifest||{};d.compositions[a]=g};d.plugin.effect=d.effect=d.compose;var A=/^(?:\.|#|\[)/;d.dom={debug:false,find:function(a,g){var l=null;a=a.trim();g=
42
- g||f;if(a){if(!A.test(a)){l=f.getElementById(a);if(l!==null)return l}try{l=g.querySelector(a)}catch(k){if(d.dom.debug)throw Error(k);}}return l}};var y=/\?/,x={url:"",data:"",dataType:"",success:d.nop,type:"GET",async:true,xhr:function(){return new r.XMLHttpRequest}};d.xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;if(a.dataType&&(a.dataType==="jsonp"||a.dataType==="script"))d.xhr.getJSONP(a.url,a.success,a.dataType==="script");else{a=d.extend({},x,a);a.ajax=a.xhr();if(a.ajax){if(a.type===
43
- "GET"&&a.data){a.url+=(y.test(a.url)?"&":"?")+a.data;a.data=null}a.ajax.open(a.type,a.url,a.async);a.ajax.send(a.data||null);return d.xhr.httpData(a)}}};d.xhr.httpData=function(a){var g,l=null,k,t=null;a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{l=JSON.parse(a.ajax.responseText)}catch(u){}g={xml:a.ajax.responseXML,text:a.ajax.responseText,json:l};if(!g.xml||!g.xml.documentElement){g.xml=null;try{k=new DOMParser;t=k.parseFromString(a.ajax.responseText,"text/xml");if(!t.getElementsByTagName("parsererror").length)g.xml=
44
- t}catch(v){}}if(a.dataType)g=g[a.dataType];a.success.call(a.ajax,g)}};return g};d.xhr.getJSONP=function(a,g,l){var k=f.head||f.getElementsByTagName("head")[0]||f.documentElement,t=f.createElement("script"),u=false,v=[];v=/(=)\?(?=&|$)|\?\?/;var z,C;if(!l){C=a.match(/(callback=[^&]*)/);if(C!==null&&C.length){v=C[1].split("=")[1];if(v==="?")v="jsonp";z=d.guid(v);a=a.replace(/(callback=[^&]*)/,"callback="+z)}else{z=d.guid("jsonp");if(v.test(a))a=a.replace(v,"$1"+z);v=a.split(/\?(.+)?/);a=v[0]+"?";if(v[1])a+=
45
- v[1]+"&";a+="callback="+z}window[z]=function(E){g&&g(E);u=true}}t.addEventListener("load",function(){l&&g&&g();u&&delete window[z];k.removeChild(t)},false);t.src=a;k.insertBefore(t,k.firstChild)};d.getJSONP=d.xhr.getJSONP;d.getScript=d.xhr.getScript=function(a,g){return d.xhr.getJSONP(a,g,true)};d.util={toSeconds:function(a,g){var l=/^([0-9]+:){0,2}[0-9]+([.;][0-9]+)?$/,k,t,u;if(typeof a==="number")return a;typeof a==="string"&&!l.test(a)&&d.error("Invalid time format");l=a.split(":");k=l.length-
46
- 1;t=l[k];if(t.indexOf(";")>-1){t=t.split(";");u=0;if(g&&typeof g==="number")u=parseFloat(t[1],10)/g;l[k]=parseInt(t[0],10)+u}k=l[0];return{1:parseFloat(k,10),2:parseInt(k,10)*60+parseFloat(l[1],10),3:parseInt(k,10)*3600+parseInt(l[1],10)*60+parseFloat(l[2],10)}[l.length||1]}};d.p.cue=d.p.exec;d.protect={natives:function(a){return Object.keys?Object.keys(a):function(g){var l,k=[];for(l in g)i.call(g,l)&&k.push(l);return k}(a)}(d.p).map(function(a){return a.toLowerCase()})};d.forEach({listen:"on",unlisten:"off",
47
- trigger:"emit",exec:"cue"},function(a,g){var l=d.p[g];d.p[g]=function(){if(typeof console!=="undefined"&&console.warn){console.warn("Deprecated method '"+g+"', "+(a==null?"do not use.":"use '"+a+"' instead."));d.p[g]=l}return d.p[a].apply(this,[].slice.call(arguments))}});r.Popcorn=d}else{r.Popcorn={isSupported:false};for(c="byId forEach extend effects error guid sizeOf isArray nop position disable enable destroyaddTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId timeUpdate plugin removePlugin compose effect xhr getJSONP getScript".split(/\s+/);c.length;)r.Popcorn[c.shift()]=
48
- function(){}}})(window,window.document);(function(r,f){var n=r.document,c=r.location,b=/:\/\//,e=c.href.replace(c.href.split("/").slice(-1)[0],""),h=function(j,p,m){j=j||0;p=(p||j||0)+1;m=m||1;p=Math.ceil((p-j)/m)||0;var o=0,q=[];for(q.length=p;o<p;){q[o++]=j;j+=m}return q};f.sequence=function(j,p){return new f.sequence.init(j,p)};f.sequence.init=function(j,p){this.parent=n.getElementById(j);this.seqId=f.guid("__sequenced");this.queue=[];this.playlist=[];this.inOuts={ofVideos:[],ofClips:[]};this.dims={width:0,height:0};this.active=0;this.playing=
49
- this.cycling=false;this.times={last:0};this.events={};var m=this,o=0;f.forEach(p,function(q,s){var d=n.createElement("video");d.preload="auto";d.controls=true;d.style.display=s&&"none"||"";d.id=m.seqId+"-"+s;m.queue.push(d);var A=q["in"],y=q.out;m.inOuts.ofVideos.push({"in":A!==undefined&&A||1,out:y!==undefined&&y||0});m.inOuts.ofVideos[s].out=m.inOuts.ofVideos[s].out||m.inOuts.ofVideos[s]["in"]+2;d.src=!b.test(q.src)?e+q.src:q.src;d.setAttribute("data-sequence-owner",j);d.setAttribute("data-sequence-guid",
50
- m.seqId);d.setAttribute("data-sequence-id",s);d.setAttribute("data-sequence-clip",[m.inOuts.ofVideos[s]["in"],m.inOuts.ofVideos[s].out].join(":"));m.parent.appendChild(d);m.playlist.push(f("#"+d.id))});m.inOuts.ofVideos.forEach(function(q){q={"in":o,out:o+(q.out-q["in"])};m.inOuts.ofClips.push(q);o=q.out+1});f.forEach(this.queue,function(q,s){function d(){if(!s){m.dims.width=q.videoWidth;m.dims.height=q.videoHeight}q.currentTime=m.inOuts.ofVideos[s]["in"]-0.5;q.removeEventListener("canplaythrough",
51
- d,false);return true}q.addEventListener("canplaythrough",d,false);q.addEventListener("play",function(){m.playing=true},false);q.addEventListener("pause",function(){m.playing=false},false);q.addEventListener("timeupdate",function(A){A=A.srcElement||A.target;A=+(A.dataset&&A.dataset.sequenceId||A.getAttribute("data-sequence-id"));var y=Math.floor(q.currentTime);if(m.times.last!==y&&A===m.active){m.times.last=y;y===m.inOuts.ofVideos[A].out&&f.sequence.cycle.call(m,A)}},false)});return this};f.sequence.init.prototype=
52
- f.sequence.prototype;f.sequence.cycle=function(j){this.queue||f.error("Popcorn.sequence.cycle is not a public method");var p=this.queue,m=this.inOuts.ofVideos,o=p[j],q=0,s;if(p[j+1])q=j+1;if(p[j+1]){p=p[q];m=m[q];f.extend(p,{width:this.dims.width,height:this.dims.height});s=this.playlist[q];o.pause();this.active=q;this.times.last=m["in"]-1;s.currentTime(m["in"]);s[q?"play":"pause"]();this.trigger("cycle",{position:{previous:j,current:q}});if(q){o.style.display="none";p.style.display=""}this.cycling=
53
- false}else this.playlist[j].pause();return this};var i=["timeupdate","play","pause"];f.extend(f.sequence.prototype,{eq:function(j){return this.playlist[j]},remove:function(){this.parent.innerHTML=null},clip:function(j){return this.inOuts.ofVideos[j]},duration:function(){for(var j=0,p=this.inOuts.ofClips,m=0;m<p.length;m++)j+=p[m].out-p[m]["in"]+1;return j-1},play:function(){this.playlist[this.active].play();return this},exec:function(j,p){var m=this.active;this.inOuts.ofClips.forEach(function(o,q){if(j>=
54
- o["in"]&&j<=o.out)m=q});j+=this.inOuts.ofVideos[m]["in"]-this.inOuts.ofClips[m]["in"];f.addTrackEvent(this.playlist[m],{start:j-1,end:j,_running:false,_natives:{start:p||f.nop,end:f.nop,type:"exec"}});return this},listen:function(j,p){var m=this,o=this.playlist,q=o.length,s=0;if(!p)p=f.nop;if(f.Events.Natives.indexOf(j)>-1)f.forEach(o,function(d){d.listen(j,function(A){A.active=m;if(i.indexOf(j)>-1)p.call(d,A);else++s===q&&p.call(d,A)})});else{this.events[j]||(this.events[j]={});o=p.name||f.guid("__"+
55
- j);this.events[j][o]=p}return this},unlisten:function(){},trigger:function(j,p){var m=this;if(!(f.Events.Natives.indexOf(j)>-1)){this.events[j]&&f.forEach(this.events[j],function(o){o.call(m,{type:j},p)});return this}}});f.forEach(f.manifest,function(j,p){f.sequence.prototype[p]=function(m){var o={},q=[],s,d,A,y,x;for(s=0;s<this.inOuts.ofClips.length;s++){q=this.inOuts.ofClips[s];d=h(q["in"],q.out);A=d.indexOf(m.start);y=d.indexOf(m.end);if(A>-1)o[s]=f.extend({},q,{start:d[A],clipIdx:A});if(y>-1)o[s]=
56
- f.extend({},q,{end:d[y],clipIdx:y})}s=Object.keys(o).map(function(g){return+g});q=h(s[0],s[1]);for(s=0;s<q.length;s++){A={};y=q[s];var a=o[y];if(a){x=this.inOuts.ofVideos[y];d=a.clipIdx;x=h(x["in"],x.out);if(a.start){A.start=x[d];A.end=x[x.length-1]}if(a.end){A.start=x[0];A.end=x[d]}}else{A.start=this.inOuts.ofVideos[y]["in"];A.end=this.inOuts.ofVideos[y].out}this.playlist[y][p](f.extend({},m,A))}return this}})})(this,Popcorn);(function(r){document.addEventListener("DOMContentLoaded",function(){var f=document.querySelectorAll("[data-timeline-sources]");r.forEach(f,function(n,c){var b=f[c],e,h,i;if(!b.id)b.id=r.guid("__popcorn");if(b.nodeType&&b.nodeType===1){i=r("#"+b.id);e=(b.getAttribute("data-timeline-sources")||"").split(",");e[0]&&r.forEach(e,function(j){h=j.split("!");if(h.length===1){h=j.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/)[2].split(".");h[0]="parse"+h[1].toUpperCase();h[1]=j}e[0]&&i[h[0]]&&i[h[0]](h[1])});i.autoplay()&&
57
- i.play()}})},false)})(Popcorn);(function(r,f){function n(e){e=typeof e==="string"?e:[e.language,e.region].join("-");var h=e.split("-");return{iso6391:e,language:h[0]||"",region:h[1]||""}}var c=r.navigator,b=n(c.userLanguage||c.language);f.locale={get:function(){return b},set:function(e){b=n(e);f.locale.broadcast();return b},broadcast:function(e){var h=f.instances,i=h.length,j=0,p;for(e=e||"locale:changed";j<i;j++){p=h[j];e in p.data.events&&p.trigger(e)}}}})(this,this.Popcorn);(function(r){var f=Object.prototype.hasOwnProperty;r.parsers={};r.parser=function(n,c,b){if(r.protect.natives.indexOf(n.toLowerCase())>=0)r.error("'"+n+"' is a protected function name");else{if(typeof c==="function"&&!b){b=c;c=""}if(!(typeof b!=="function"||typeof c!=="string")){var e={};e[n]=function(h,i){if(!h)return this;var j=this;r.xhr({url:h,dataType:c,success:function(p){var m,o,q=0;p=b(p).data||[];if(m=p.length){for(;q<m;q++){o=p[q];for(var s in o)f.call(o,s)&&j[s]&&j[s](o[s])}i&&i()}}});
58
- return this};r.extend(r.p,e);return e}}}})(Popcorn);(function(r){var f=function(b,e){b=b||r.nop;e=e||r.nop;return function(){b.apply(this,arguments);e.apply(this,arguments)}},n=/^.*\.(ogg|oga|aac|mp3|wav)($|\?)/,c=/^.*\.(ogg|oga|aac|mp3|wav|ogg|ogv|mp4|webm)($|\?)/;r.player=function(b,e){if(!r[b]){e=e||{};var h=function(i,j,p){p=p||{};var m=new Date/1E3,o=m,q=0,s=0,d=1,A=false,y={},x=typeof i==="string"?r.dom.find(i):i,a={};Object.prototype.__defineGetter__||(a=x||document.createElement("div"));for(var g in x)if(!(g in a))if(typeof x[g]==="object")a[g]=
59
- x[g];else if(typeof x[g]==="function")a[g]=function(k){return"length"in x[k]&&!x[k].call?x[k]:function(){return x[k].apply(x,arguments)}}(g);else r.player.defineProperty(a,g,{get:function(k){return function(){return x[k]}}(g),set:r.nop,configurable:true});var l=function(){m=new Date/1E3;if(!a.paused){a.currentTime+=m-o;a.dispatchEvent("timeupdate");setTimeout(l,10)}o=m};a.play=function(){this.paused=false;if(a.readyState>=4){o=new Date/1E3;a.dispatchEvent("play");l()}};a.pause=function(){this.paused=
60
- true;a.dispatchEvent("pause")};r.player.defineProperty(a,"currentTime",{get:function(){return q},set:function(k){q=+k;a.dispatchEvent("timeupdate");return q},configurable:true});r.player.defineProperty(a,"volume",{get:function(){return d},set:function(k){d=+k;a.dispatchEvent("volumechange");return d},configurable:true});r.player.defineProperty(a,"muted",{get:function(){return A},set:function(k){A=+k;a.dispatchEvent("volumechange");return A},configurable:true});r.player.defineProperty(a,"readyState",
61
- {get:function(){return s},set:function(k){return s=k},configurable:true});a.addEventListener=function(k,t){y[k]||(y[k]=[]);y[k].push(t);return t};a.removeEventListener=function(k,t){var u,v=y[k];if(v){for(u=y[k].length-1;u>=0;u--)t===v[u]&&v.splice(u,1);return t}};a.dispatchEvent=function(k){var t,u=k.type;if(!u){u=k;if(k=r.events.getInterface(u)){t=document.createEvent(k);t.initEvent(u,true,true,window,1)}}if(y[u])for(k=y[u].length-1;k>=0;k--)y[u][k].call(this,t,this)};a.src=j||"";a.duration=0;a.paused=
62
- true;a.ended=0;p&&p.events&&r.forEach(p.events,function(k,t){a.addEventListener(t,k,false)});if(e._canPlayType(x.nodeName,j)!==false)if(e._setup)e._setup.call(a,p);else{a.readyState=4;a.dispatchEvent("loadedmetadata");a.dispatchEvent("loadeddata");a.dispatchEvent("canplaythrough")}else setTimeout(function(){a.dispatchEvent("error")},0);i=new r.p.init(a,p);if(e._teardown)i.destroy=f(i.destroy,function(){e._teardown.call(a,p)});return i};h.canPlayType=e._canPlayType=e._canPlayType||r.nop;r[b]=r.player.registry[b]=
63
- h}};r.player.registry={};r.player.defineProperty=Object.defineProperty||function(b,e,h){b.__defineGetter__(e,h.get||r.nop);b.__defineSetter__(e,h.set||r.nop)};r.player.playerQueue=function(){var b=[],e=false;return{next:function(){e=false;b.shift();b[0]&&b[0]()},add:function(h){b.push(function(){e=true;h&&h()});!e&&b[0]()}}};r.smart=function(b,e,h){var i=["AUDIO","VIDEO"],j,p=r.dom.find(b),m;j=document.createElement("video");var o={ogg:"video/ogg",ogv:"video/ogg",oga:"audio/ogg",webm:"video/webm",
64
- mp4:"video/mp4",mp3:"audio/mp3"};if(p){if(i.indexOf(p.nodeName)>-1&&!e){if(typeof e==="object")h=e;return r(p,h)}if(typeof e==="string")e=[e];b=0;for(srcLength=e.length;b<srcLength;b++){m=c.exec(e[b]);m=!m||!m[1]?false:j.canPlayType(o[m[1]]);if(m){e=e[b];break}for(var q in r.player.registry)if(r.player.registry.hasOwnProperty(q))if(r.player.registry[q].canPlayType(p.nodeName,e[b]))return r[q](p,e[b],h)}if(i.indexOf(p.nodeName)===-1){j=typeof e==="string"?e:e.length?e[0]:e;b=document.createElement(n.exec(j)?
65
- i[0]:i[1]);b.controls=true;p.appendChild(b);p=b}h&&h.events&&h.events.error&&p.addEventListener("error",h.events.error,false);p.src=e;return r(p,h)}else r.error("Specified target "+b+" was not found.")}})(Popcorn);(function(r){var f=function(n,c){var b=0,e=0,h;r.forEach(c.classes,function(i,j){h=[];if(i==="parent")h[0]=document.querySelectorAll("#"+c.target)[0].parentNode;else h=document.querySelectorAll("#"+c.target+" "+i);b=0;for(e=h.length;b<e;b++)h[b].classList.toggle(j)})};r.compose("applyclass",{manifest:{about:{name:"Popcorn applyclass Effect",version:"0.1",author:"@scottdowne",website:"scottdowne.wordpress.com"},options:{}},_setup:function(n){n.classes={};n.applyclass=n.applyclass||"";for(var c=n.applyclass.replace(/\s/g,
66
- "").split(","),b=[],e=0,h=c.length;e<h;e++){b=c[e].split(":");if(b[0])n.classes[b[0]]=b[1]||""}},start:f,end:f})})(Popcorn);(function(r){var f=/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(youtu|vimeo|soundcloud|baseplayer)/,n={},c={vimeo:false,youtube:false,soundcloud:false,module:false};Object.defineProperty(n,void 0,{get:function(){return c[void 0]},set:function(b){c[void 0]=b}});r.plugin("mediaspawner",{manifest:{about:{name:"Popcorn Media Spawner Plugin",version:"0.1",author:"Matthew Schranz, @mjschranz",website:"mschranz.wordpress.com"},options:{source:{elem:"input",type:"text",label:"Media Source","default":"http://www.youtube.com/watch?v=CXDstfD9eJ0"},
67
- caption:{elem:"input",type:"text",label:"Media Caption","default":"Popcorn Popping",optional:true},target:"mediaspawner-container",start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},autoplay:{elem:"input",type:"checkbox",label:"Autoplay Video",optional:true},width:{elem:"input",type:"number",label:"Media Width","default":400,units:"px",optional:true},height:{elem:"input",type:"number",label:"Media Height","default":200,units:"px",optional:true}}},_setup:function(b){function e(){function o(){if(j!==
68
- "HTML5"&&!window.Popcorn[j])setTimeout(function(){o()},300);else{b.id=b._container.id;b._container.style.width=b.width+"px";b._container.style.height=b.height+"px";b.popcorn=r.smart("#"+b.id,b.source);j==="HTML5"&&b.popcorn.controls(true);b._container.style.width="0px";b._container.style.height="0px";b._container.style.visibility="hidden";b._container.style.overflow="hidden"}}if(j!=="HTML5"&&!window.Popcorn[j]&&!n[j]){n[j]=true;r.getScript("http://popcornjs.org/code/players/"+j+"/popcorn."+j+".js",
69
- function(){o()})}else o()}function h(){window.Popcorn.player?e():setTimeout(function(){h()},300)}var i=document.getElementById(b.target)||{},j,p,m;if(p=f.exec(b.source)){j=p[1];if(j==="youtu")j="youtube"}else j="HTML5";b._type=j;b._container=document.createElement("div");p=b._container;p.id="mediaSpawnerdiv-"+r.guid();b.width=b.width||400;b.height=b.height||200;if(b.caption){m=document.createElement("div");m.innerHTML=b.caption;m.style.display="none";b._capCont=m;p.appendChild(m)}i&&i.appendChild(p);
70
- if(!window.Popcorn.player&&!n.module){n.module=true;r.getScript("http://popcornjs.org/code/modules/player/popcorn.player.js",h)}else h()},start:function(b,e){if(e._capCont)e._capCont.style.display="";e._container.style.width=e.width+"px";e._container.style.height=e.height+"px";e._container.style.visibility="visible";e._container.style.overflow="visible";e.autoplay&&e.popcorn.play()},end:function(b,e){if(e._capCont)e._capCont.style.display="none";e._container.style.width="0px";e._container.style.height=
71
- "0px";e._container.style.visibility="hidden";e._container.style.overflow="hidden";e.popcorn.pause()},_teardown:function(b){b.popcorn&&b.popcorn.destory&&b.popcorn.destroy();document.getElementById(b.target)&&document.getElementById(b.target).removeChild(b._container)}})})(Popcorn,this);(function(r){r.plugin("code",function(f){var n=false,c=this,b=function(){var e=function(h){return function(i,j){var p=function(){n&&i.call(c,j);n&&h(p)};p()}};return window.webkitRequestAnimationFrame?e(window.webkitRequestAnimationFrame):window.mozRequestAnimationFrame?e(window.mozRequestAnimationFrame):e(function(h){window.setTimeout(h,16)})}();if(!f.onStart||typeof f.onStart!=="function")f.onStart=r.nop;if(f.onEnd&&typeof f.onEnd!=="function")f.onEnd=undefined;if(f.onFrame&&typeof f.onFrame!==
72
- "function")f.onFrame=undefined;return{start:function(e,h){h.onStart.call(c,h);if(h.onFrame){n=true;b(h.onFrame,h)}},end:function(e,h){if(h.onFrame)n=false;h.onEnd&&h.onEnd.call(c,h)}}},{about:{name:"Popcorn Code Plugin",version:"0.1",author:"David Humphrey (@humphd)",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},onStart:{elem:"input",type:"function",label:"onStart"},onFrame:{elem:"input",type:"function",label:"onFrame",
73
- optional:true},onEnd:{elem:"input",type:"function",label:"onEnd"}}})})(Popcorn);(function(r){var f=0;r.plugin("flickr",function(n){var c,b=document.getElementById(n.target),e,h,i,j,p=n.numberofimages||4,m=n.height||"50px",o=n.width||"50px",q=n.padding||"5px",s=n.border||"0px";c=document.createElement("div");c.id="flickr"+f;c.style.width="100%";c.style.height="100%";c.style.display="none";f++;b&&b.appendChild(c);var d=function(){if(e)setTimeout(function(){d()},5);else{h="http://api.flickr.com/services/rest/?method=flickr.people.findByUsername&";h+="username="+n.username+"&api_key="+
74
- n.apikey+"&format=json&jsoncallback=flickr";r.getJSONP(h,function(y){e=y.user.nsid;A()})}},A=function(){h="http://api.flickr.com/services/feeds/photos_public.gne?";if(e)h+="id="+e+"&";if(n.tags)h+="tags="+n.tags+"&";h+="lang=en-us&format=json&jsoncallback=flickr";r.xhr.getJSONP(h,function(y){var x=document.createElement("div");x.innerHTML="<p style='padding:"+q+";'>"+y.title+"<p/>";r.forEach(y.items,function(a,g){if(g<p){i=document.createElement("a");i.setAttribute("href",a.link);i.setAttribute("target",
75
- "_blank");j=document.createElement("img");j.setAttribute("src",a.media.m);j.setAttribute("height",m);j.setAttribute("width",o);j.setAttribute("style","border:"+s+";padding:"+q);i.appendChild(j);x.appendChild(i)}else return false});c.appendChild(x)})};if(n.username&&n.apikey)d();else{e=n.userid;A()}return{start:function(){c.style.display="inline"},end:function(){c.style.display="none"},_teardown:function(y){document.getElementById(y.target)&&document.getElementById(y.target).removeChild(c)}}},{about:{name:"Popcorn Flickr Plugin",
76
- version:"0.2",author:"Scott Downe, Steven Weerdenburg, Annasob",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},userid:{elem:"input",type:"text",label:"User ID",optional:true},tags:{elem:"input",type:"text",label:"Tags"},username:{elem:"input",type:"text",label:"Username",optional:true},apikey:{elem:"input",type:"text",label:"API Key",optional:true},target:"flickr-container",height:{elem:"input",type:"text",
77
- label:"Height","default":"50px",optional:true},width:{elem:"input",type:"text",label:"Width","default":"50px",optional:true},padding:{elem:"input",type:"text",label:"Padding",optional:true},border:{elem:"input",type:"text",label:"Border","default":"5px",optional:true},numberofimages:{elem:"input",type:"number","default":4,label:"Number of Images"}}})})(Popcorn);(function(r){r.plugin("footnote",{manifest:{about:{name:"Popcorn Footnote Plugin",version:"0.2",author:"@annasob, @rwaldron",website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},text:{elem:"input",type:"text",label:"Text"},target:"footnote-container"}},_setup:function(f){var n=r.dom.find(f.target);f._container=document.createElement("div");f._container.style.display="none";f._container.innerHTML=f.text;n.appendChild(f._container)},
78
- start:function(f,n){n._container.style.display="inline"},end:function(f,n){n._container.style.display="none"},_teardown:function(f){var n=r.dom.find(f.target);n&&n.removeChild(f._container)}})})(Popcorn);(function(r){function f(b){return String(b).replace(/&(?!\w+;)|[<>"']/g,function(e){return c[e]||e})}function n(b,e){var h=b.container=document.createElement("div"),i=h.style,j=b.media,p=function(){var m=b.position();i.fontSize="18px";i.width=j.offsetWidth+"px";i.top=m.top+j.offsetHeight-h.offsetHeight-40+"px";i.left=m.left+"px";setTimeout(p,10)};h.id=e||"";i.position="absolute";i.color="white";i.textShadow="black 2px 2px 6px";i.fontWeight="bold";i.textAlign="center";p();b.media.parentNode.appendChild(h);
79
- return h}var c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};r.plugin("text",{manifest:{about:{name:"Popcorn Text Plugin",version:"0.1",author:"@humphd"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},text:{elem:"input",type:"text",label:"Text","default":"Popcorn.js"},escape:{elem:"input",type:"checkbox",label:"Escape"},multiline:{elem:"input",type:"checkbox",label:"Multiline"}}},_setup:function(b){var e,h,i=b._container=document.createElement("div");
80
- i.style.display="none";if(b.target)if(e=r.dom.find(b.target)){if(["VIDEO","AUDIO"].indexOf(e.nodeName)>-1)e=n(this,b.target+"-overlay")}else e=n(this,b.target);else e=this.container?this.container:n(this);b._target=e;h=b.escape?f(b.text):b.text;h=b.multiline?h.replace(/\r?\n/gm,"<br>"):h;i.innerHTML=h||"";e.appendChild(i)},start:function(b,e){e._container.style.display="inline"},end:function(b,e){e._container.style.display="none"},_teardown:function(b){var e=b._target;e&&e.removeChild(b._container)}})})(Popcorn);var googleCallback;
81
- (function(r){function f(i,j,p){i=i.type?i.type.toUpperCase():"HYBRID";var m;if(i==="STAMEN-WATERCOLOR"||i==="STAMEN-TERRAIN"||i==="STAMEN-TONER")m=i.replace("STAMEN-","").toLowerCase();p=new google.maps.Map(p,{mapTypeId:m?m:google.maps.MapTypeId[i],mapTypeControlOptions:{mapTypeIds:[]}});m&&p.mapTypes.set(m,new google.maps.StamenMapType(m));p.getDiv().style.display="none";return p}var n=1,c=false,b=false,e,h;googleCallback=function(i){if(typeof google!=="undefined"&&google.maps&&google.maps.Geocoder&&
82
- google.maps.LatLng){e=new google.maps.Geocoder;r.getScript("//maps.stamen.com/js/tile.stamen.js",function(){b=true})}else setTimeout(function(){googleCallback(i)},1)};h=function(){if(document.body){c=true;r.getScript("//maps.google.com/maps/api/js?sensor=false&callback=googleCallback")}else setTimeout(function(){h()},1)};r.plugin("googlemap",function(i){var j,p,m,o=document.getElementById(i.target);i.type=i.type||"ROADMAP";i.zoom=i.zoom||1;i.lat=i.lat||0;i.lng=i.lng||0;c||h();j=document.createElement("div");
83
- j.id="actualmap"+n;j.style.width=i.width||"100%";j.style.height=i.height?i.height:o&&o.clientHeight?o.clientHeight+"px":"100%";n++;o&&o.appendChild(j);var q=function(){if(b){if(j)if(i.location)e.geocode({address:i.location},function(s,d){if(j&&d===google.maps.GeocoderStatus.OK){i.lat=s[0].geometry.location.lat();i.lng=s[0].geometry.location.lng();m=new google.maps.LatLng(i.lat,i.lng);p=f(i,m,j)}});else{m=new google.maps.LatLng(i.lat,i.lng);p=f(i,m,j)}}else setTimeout(function(){q()},5)};q();return{start:function(s,
84
- d){var A=this,y,x=function(){if(p){d._map=p;p.getDiv().style.display="block";google.maps.event.trigger(p,"resize");p.setCenter(m);if(d.zoom&&typeof d.zoom!=="number")d.zoom=+d.zoom;p.setZoom(d.zoom);if(d.heading&&typeof d.heading!=="number")d.heading=+d.heading;if(d.pitch&&typeof d.pitch!=="number")d.pitch=+d.pitch;if(d.type==="STREETVIEW"){p.setStreetView(y=new google.maps.StreetViewPanorama(j,{position:m,pov:{heading:d.heading=d.heading||0,pitch:d.pitch=d.pitch||0,zoom:d.zoom}}));var a=function(z,
85
- C){var E=google.maps.geometry.spherical.computeHeading;setTimeout(function(){var B=A.media.currentTime;if(typeof d.tween==="object"){for(var w=0,D=z.length;w<D;w++){var F=z[w];if(B>=F.interval*(w+1)/1E3&&(B<=F.interval*(w+2)/1E3||B>=F.interval*D/1E3)){u.setPosition(new google.maps.LatLng(F.position.lat,F.position.lng));u.setPov({heading:F.pov.heading||E(F,z[w+1])||0,zoom:F.pov.zoom||0,pitch:F.pov.pitch||0})}}a(z,z[0].interval)}else{w=0;for(D=z.length;w<D;w++){F=d.interval;if(B>=F*(w+1)/1E3&&(B<=F*
86
- (w+2)/1E3||B>=F*D/1E3)){g.setPov({heading:E(z[w],z[w+1])||0,zoom:d.zoom,pitch:d.pitch||0});g.setPosition(l[w])}}a(l,d.interval)}},C)};if(d.location&&typeof d.tween==="string"){var g=y,l=[],k=new google.maps.DirectionsService,t=new google.maps.DirectionsRenderer(g);k.route({origin:d.location,destination:d.tween,travelMode:google.maps.TravelMode.DRIVING},function(z,C){if(C==google.maps.DirectionsStatus.OK){t.setDirections(z);for(var E=z.routes[0].overview_path,B=0,w=E.length;B<w;B++)l.push(new google.maps.LatLng(E[B].lat(),
87
- E[B].lng()));d.interval=d.interval||1E3;a(l,10)}})}else if(typeof d.tween==="object"){var u=y;k=0;for(var v=d.tween.length;k<v;k++){d.tween[k].interval=d.tween[k].interval||1E3;a(d.tween,10)}}}d.onmaploaded&&d.onmaploaded(d,p)}else setTimeout(function(){x()},13)};x()},end:function(){if(p)p.getDiv().style.display="none"},_teardown:function(s){var d=document.getElementById(s.target);d&&d.removeChild(j);j=p=m=null;s._map=null}}},{about:{name:"Popcorn Google Map Plugin",version:"0.1",author:"@annasob",
88
- website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"start",label:"Start"},end:{elem:"input",type:"start",label:"End"},target:"map-container",type:{elem:"select",options:["ROADMAP","SATELLITE","STREETVIEW","HYBRID","TERRAIN","STAMEN-WATERCOLOR","STAMEN-TERRAIN","STAMEN-TONER"],label:"Map Type",optional:true},zoom:{elem:"input",type:"text",label:"Zoom","default":0,optional:true},lat:{elem:"input",type:"text",label:"Lat",optional:true},lng:{elem:"input",type:"text",label:"Lng",optional:true},
89
- location:{elem:"input",type:"text",label:"Location","default":"Toronto, Ontario, Canada"},heading:{elem:"input",type:"text",label:"Heading","default":0,optional:true},pitch:{elem:"input",type:"text",label:"Pitch","default":1,optional:true}}})})(Popcorn);(function(r){function f(b){function e(){var p=b.getBoundingClientRect(),m=i.getBoundingClientRect();if(m.left!==p.left)i.style.left=p.left+"px";if(m.top!==p.top)i.style.top=p.top+"px"}var h=-1,i=document.createElement("div"),j=getComputedStyle(b).zIndex;i.setAttribute("data-popcorn-helper-container",true);i.style.position="absolute";i.style.zIndex=isNaN(j)?n:j+1;document.body.appendChild(i);return{element:i,start:function(){h=setInterval(e,c)},stop:function(){clearInterval(h);h=-1},destroy:function(){document.body.removeChild(i);
90
- h!==-1&&clearInterval(h)}}}var n=2E3,c=10;r.plugin("image",{manifest:{about:{name:"Popcorn image Plugin",version:"0.1",author:"Scott Downe",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},src:{elem:"input",type:"url",label:"Image URL","default":"http://mozillapopcorn.org/wp-content/themes/popcorn/images/for_developers.png"},href:{elem:"input",type:"url",label:"Link","default":"http://mozillapopcorn.org/wp-content/themes/popcorn/images/for_developers.png",
91
- optional:true},target:"image-container",text:{elem:"input",type:"text",label:"Caption","default":"Popcorn.js",optional:true}}},_setup:function(b){var e=document.createElement("img"),h=document.getElementById(b.target);b.anchor=document.createElement("a");b.anchor.style.position="relative";b.anchor.style.textDecoration="none";b.anchor.style.display="none";if(h)if(["VIDEO","AUDIO"].indexOf(h.nodeName)>-1){b.trackedContainer=f(h);b.trackedContainer.element.appendChild(b.anchor)}else h&&h.appendChild(b.anchor);
92
- e.addEventListener("load",function(){e.style.borderStyle="none";b.anchor.href=b.href||b.src||"#";b.anchor.target="_blank";var i,j;e.style.height=h.style.height;e.style.width=h.style.width;b.anchor.appendChild(e);if(b.text){i=e.height/12+"px";j=document.createElement("div");r.extend(j.style,{color:"black",fontSize:i,fontWeight:"bold",position:"relative",textAlign:"center",width:e.style.width||e.width+"px",zIndex:"10"});j.innerHTML=b.text||"";j.style.top=(e.style.height.replace("px","")||e.height)/
93
- 2-j.offsetHeight/2+"px";b.anchor.insertBefore(j,e)}},false);e.src=b.src},start:function(b,e){e.anchor.style.display="inline";e.trackedContainer&&e.trackedContainer.start()},end:function(b,e){e.anchor.style.display="none";e.trackedContainer&&e.trackedContainer.stop()},_teardown:function(b){if(b.trackedContainer)b.trackedContainer.destroy();else b.anchor.parentNode&&b.anchor.parentNode.removeChild(b.anchor)}})})(Popcorn);(function(r){var f=1,n=false;r.plugin("googlefeed",function(c){var b=function(){var j=false,p=0,m=document.getElementsByTagName("link"),o=m.length,q=document.head||document.getElementsByTagName("head")[0],s=document.createElement("link");if(window.GFdynamicFeedControl)n=true;else r.getScript("//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js",function(){n=true});for(;p<o;p++)if(m[p].href==="//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css")j=true;if(!j){s.type=
94
- "text/css";s.rel="stylesheet";s.href="//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";q.insertBefore(s,q.firstChild)}};window.google?b():r.getScript("//www.google.com/jsapi",function(){google.load("feeds","1",{callback:function(){b()}})});var e=document.createElement("div"),h=document.getElementById(c.target),i=function(){if(n)c.feed=new GFdynamicFeedControl(c.url,e,{vertical:c.orientation.toLowerCase()==="vertical"?true:false,horizontal:c.orientation.toLowerCase()==="horizontal"?
95
- true:false,title:c.title=c.title||"Blog"});else setTimeout(function(){i()},5)};if(!c.orientation||c.orientation.toLowerCase()!=="vertical"&&c.orientation.toLowerCase()!=="horizontal")c.orientation="vertical";e.style.display="none";e.id="_feed"+f;e.style.width="100%";e.style.height="100%";f++;h&&h.appendChild(e);i();return{start:function(){e.setAttribute("style","display:inline")},end:function(){e.setAttribute("style","display:none")},_teardown:function(j){document.getElementById(j.target)&&document.getElementById(j.target).removeChild(e);
96
- delete j.feed}}},{about:{name:"Popcorn Google Feed Plugin",version:"0.1",author:"David Seifried",website:"dseifried.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"feed-container",url:{elem:"input",type:"url",label:"Feed URL","default":"http://planet.mozilla.org/rss20.xml"},title:{elem:"input",type:"text",label:"Title","default":"Planet Mozilla",optional:true},orientation:{elem:"select",options:["Vertical","Horizontal"],
97
- label:"Orientation","default":"Vertical",optional:true}}})})(Popcorn);(function(r){var f=0,n=function(c,b){var e=c.container=document.createElement("div"),h=e.style,i=c.media,j=function(){var p=c.position();h.fontSize="18px";h.width=i.offsetWidth+"px";h.top=p.top+i.offsetHeight-e.offsetHeight-40+"px";h.left=p.left+"px";setTimeout(j,10)};e.id=b||r.guid();h.position="absolute";h.color="white";h.textShadow="black 2px 2px 6px";h.fontWeight="bold";h.textAlign="center";j();c.media.parentNode.appendChild(e);return e};r.plugin("subtitle",{manifest:{about:{name:"Popcorn Subtitle Plugin",
98
- version:"0.1",author:"Scott Downe",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"text",label:"Start"},end:{elem:"input",type:"text",label:"End"},target:"subtitle-container",text:{elem:"input",type:"text",label:"Text"}}},_setup:function(c){var b=document.createElement("div");b.id="subtitle-"+f++;b.style.display="none";!this.container&&(!c.target||c.target==="subtitle-container")&&n(this);c.container=c.target&&c.target!=="subtitle-container"?document.getElementById(c.target)||
99
- n(this,c.target):this.container;document.getElementById(c.container.id)&&document.getElementById(c.container.id).appendChild(b);c.innerContainer=b;c.showSubtitle=function(){c.innerContainer.innerHTML=c.text||""}},start:function(c,b){b.innerContainer.style.display="inline";b.showSubtitle(b,b.text)},end:function(c,b){b.innerContainer.style.display="none";b.innerContainer.innerHTML=""},_teardown:function(c){c.container.removeChild(c.innerContainer)}})})(Popcorn);(function(r){var f=false;r.plugin("twitter",{manifest:{about:{name:"Popcorn Twitter Plugin",version:"0.1",author:"Scott Downe",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},src:{elem:"input",type:"text",label:"Tweet Source (# or @)","default":"@popcornjs"},target:"twitter-container",height:{elem:"input",type:"number",label:"Height","default":"200",optional:true},width:{elem:"input",type:"number",label:"Width",
100
- "default":"250",optional:true}}},_setup:function(n){if(!window.TWTR&&!f){f=true;r.getScript("//widgets.twimg.com/j/2/widget.js")}var c=document.getElementById(n.target);n.container=document.createElement("div");n.container.setAttribute("id",r.guid());n.container.style.display="none";c&&c.appendChild(n.container);var b=n.src||"";c=n.width||250;var e=n.height||200,h=/^@/.test(b),i={version:2,id:n.container.getAttribute("id"),rpp:30,width:c,height:e,interval:6E3,theme:{shell:{background:"#ffffff",color:"#000000"},
101
- tweets:{background:"#ffffff",color:"#444444",links:"#1985b5"}},features:{loop:true,timestamp:true,avatars:true,hashtags:true,toptweets:true,live:true,scrollbar:false,behavior:"default"}},j=function(p){if(window.TWTR)if(h){i.type="profile";(new TWTR.Widget(i)).render().setUser(b).start()}else{i.type="search";i.search=b;i.subject=b;(new TWTR.Widget(i)).render().start()}else setTimeout(function(){j(p)},1)};j(this)},start:function(n,c){c.container.style.display="inline"},end:function(n,c){c.container.style.display=
102
- "none"},_teardown:function(n){document.getElementById(n.target)&&document.getElementById(n.target).removeChild(n.container)}})})(Popcorn);(function(r){r.plugin("webpage",{manifest:{about:{name:"Popcorn Webpage Plugin",version:"0.1",author:"@annasob",website:"annasob.wordpress.com"},options:{id:{elem:"input",type:"text",label:"Id",optional:true},start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},src:{elem:"input",type:"url",label:"Webpage URL","default":"http://mozillapopcorn.org"},target:"iframe-container"}},_setup:function(f){var n=document.getElementById(f.target);f.src=f.src.replace(/^(https?:)?(\/\/)?/,
103
- "//");f._iframe=document.createElement("iframe");f._iframe.setAttribute("width","100%");f._iframe.setAttribute("height","100%");f._iframe.id=f.id;f._iframe.src=f.src;f._iframe.style.display="none";n&&n.appendChild(f._iframe)},start:function(f,n){n._iframe.src=n.src;n._iframe.style.display="inline"},end:function(f,n){n._iframe.style.display="none"},_teardown:function(f){document.getElementById(f.target)&&document.getElementById(f.target).removeChild(f._iframe)}})})(Popcorn);var wikiCallback;
104
- (function(r){r.plugin("wikipedia",{manifest:{about:{name:"Popcorn Wikipedia Plugin",version:"0.1",author:"@annasob",website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},lang:{elem:"input",type:"text",label:"Language","default":"english",optional:true},src:{elem:"input",type:"url",label:"Wikipedia URL","default":"http://en.wikipedia.org/wiki/Cat"},title:{elem:"input",type:"text",label:"Title","default":"Cats",optional:true},
105
- numberofwords:{elem:"input",type:"number",label:"Number of Words","default":"200",optional:true},target:"wikipedia-container"}},_setup:function(f){var n,c=r.guid();if(!f.lang)f.lang="en";f.numberofwords=f.numberofwords||200;window["wikiCallback"+c]=function(b){f._link=document.createElement("a");f._link.setAttribute("href",f.src);f._link.setAttribute("target","_blank");f._link.innerHTML=f.title||b.parse.displaytitle;f._desc=document.createElement("p");n=b.parse.text["*"].substr(b.parse.text["*"].indexOf("<p>"));
106
- n=n.replace(/((<(.|\n)+?>)|(\((.*?)\) )|(\[(.*?)\]))/g,"");n=n.split(" ");f._desc.innerHTML=n.slice(0,n.length>=f.numberofwords?f.numberofwords:n.length).join(" ")+" ...";f._fired=true};f.src&&r.getScript("//"+f.lang+".wikipedia.org/w/api.php?action=parse&props=text&redirects&page="+f.src.slice(f.src.lastIndexOf("/")+1)+"&format=json&callback=wikiCallback"+c)},start:function(f,n){var c=function(){if(n._fired){if(n._link&&n._desc)if(document.getElementById(n.target)){document.getElementById(n.target).appendChild(n._link);
107
- document.getElementById(n.target).appendChild(n._desc);n._added=true}}else setTimeout(function(){c()},13)};c()},end:function(f,n){if(n._added){document.getElementById(n.target).removeChild(n._link);document.getElementById(n.target).removeChild(n._desc)}},_teardown:function(f){if(f._added){f._link.parentNode&&document.getElementById(f.target).removeChild(f._link);f._desc.parentNode&&document.getElementById(f.target).removeChild(f._desc);delete f.target}}})})(Popcorn);(function(r){r.plugin("mustache",function(f){var n,c,b,e;r.getScript("http://mustache.github.com/extras/mustache.js");var h=!!f.dynamic,i=typeof f.template,j=typeof f.data,p=document.getElementById(f.target);f.container=p||document.createElement("div");if(i==="function")if(h)b=f.template;else e=f.template(f);else e=i==="string"?f.template:"";if(j==="function")if(h)n=f.data;else c=f.data(f);else c=j==="string"?JSON.parse(f.data):j==="object"?f.data:"";return{start:function(m,o){var q=function(){if(window.Mustache){if(n)c=
108
- n(o);if(b)e=b(o);var s=Mustache.to_html(e,c).replace(/^\s*/mg,"");o.container.innerHTML=s}else setTimeout(function(){q()},10)};q()},end:function(m,o){o.container.innerHTML=""},_teardown:function(){n=c=b=e=null}}},{about:{name:"Popcorn Mustache Plugin",version:"0.1",author:"David Humphrey (@humphd)",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"mustache-container",template:{elem:"input",type:"text",
109
- label:"Template"},data:{elem:"input",type:"text",label:"Data"},dynamic:{elem:"input",type:"checkbox",label:"Dynamic","default":true}}})})(Popcorn);(function(r){function f(c,b){if(c.map)c.map.div.style.display=b;else setTimeout(function(){f(c,b)},10)}var n=1;r.plugin("openmap",function(c){var b,e,h,i,j,p,m,o,q=document.getElementById(c.target);b=document.createElement("div");b.id="openmapdiv"+n;b.style.width="100%";b.style.height="100%";n++;q&&q.appendChild(b);o=function(){if(window.OpenLayers&&window.OpenLayers.Layer.Stamen){if(c.location){location=new OpenLayers.LonLat(0,0);r.getJSONP("//tinygeocoder.com/create-api.php?q="+c.location+"&callback=jsonp",
110
- function(d){e=new OpenLayers.LonLat(d[1],d[0])})}else e=new OpenLayers.LonLat(c.lng,c.lat);c.type=c.type||"ROADMAP";switch(c.type){case "SATELLITE":c.map=new OpenLayers.Map({div:b,maxResolution:0.28125,tileSize:new OpenLayers.Size(512,512)});var s=new OpenLayers.Layer.WorldWind("LANDSAT","//worldwind25.arc.nasa.gov/tile/tile.aspx",2.25,4,{T:"105"});c.map.addLayer(s);i=new OpenLayers.Projection("EPSG:4326");h=new OpenLayers.Projection("EPSG:4326");break;case "TERRAIN":i=new OpenLayers.Projection("EPSG:4326");
111
- h=new OpenLayers.Projection("EPSG:4326");c.map=new OpenLayers.Map({div:b,projection:h});s=new OpenLayers.Layer.WMS("USGS Terraserver","//terraserver-usa.org/ogcmap.ashx?",{layers:"DRG"});c.map.addLayer(s);break;case "STAMEN-TONER":case "STAMEN-WATERCOLOR":case "STAMEN-TERRAIN":s=c.type.replace("STAMEN-","").toLowerCase();s=new OpenLayers.Layer.Stamen(s);i=new OpenLayers.Projection("EPSG:4326");h=new OpenLayers.Projection("EPSG:900913");e=e.transform(i,h);c.map=new OpenLayers.Map({div:b,projection:h,
112
- displayProjection:i,controls:[new OpenLayers.Control.Navigation,new OpenLayers.Control.PanPanel,new OpenLayers.Control.ZoomPanel]});c.map.addLayer(s);break;default:h=new OpenLayers.Projection("EPSG:900913");i=new OpenLayers.Projection("EPSG:4326");e=e.transform(i,h);c.map=new OpenLayers.Map({div:b,projection:h,displayProjection:i});s=new OpenLayers.Layer.OSM;c.map.addLayer(s)}if(c.map){c.map.setCenter(e,c.zoom||10);c.map.div.style.display="none"}}else setTimeout(function(){o()},50)};o();return{_setup:function(s){window.OpenLayers||
113
- r.getScript("//openlayers.org/api/OpenLayers.js",function(){r.getScript("//maps.stamen.com/js/tile.stamen.js")});var d=function(){if(s.map){s.zoom=s.zoom||2;if(s.zoom&&typeof s.zoom!=="number")s.zoom=+s.zoom;s.map.setCenter(e,s.zoom);if(s.markers){var A=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style["default"]),y=function(v){clickedFeature=v.feature;if(clickedFeature.attributes.text){m=new OpenLayers.Popup.FramedCloud("featurePopup",clickedFeature.geometry.getBounds().getCenterLonLat(),
114
- new OpenLayers.Size(120,250),clickedFeature.attributes.text,null,true,function(){p.unselect(this.feature)});clickedFeature.popup=m;m.feature=clickedFeature;s.map.addPopup(m)}},x=function(v){feature=v.feature;if(feature.popup){m.feature=null;s.map.removePopup(feature.popup);feature.popup.destroy();feature.popup=null}},a=function(v){r.getJSONP("//tinygeocoder.com/create-api.php?q="+v.location+"&callback=jsonp",function(z){z=(new OpenLayers.Geometry.Point(z[1],z[0])).transform(i,h);var C=OpenLayers.Util.extend({},
115
- A);if(!v.size||isNaN(v.size))v.size=14;C.pointRadius=v.size;C.graphicOpacity=1;C.externalGraphic=v.icon;z=new OpenLayers.Feature.Vector(z,null,C);if(v.text)z.attributes={text:v.text};j.addFeatures([z])})};j=new OpenLayers.Layer.Vector("Point Layer",{style:A});s.map.addLayer(j);for(var g=0,l=s.markers.length;g<l;g++){var k=s.markers[g];if(k.text)if(!p){p=new OpenLayers.Control.SelectFeature(j);s.map.addControl(p);p.activate();j.events.on({featureselected:y,featureunselected:x})}if(k.location)a(k);
116
- else{var t=(new OpenLayers.Geometry.Point(k.lng,k.lat)).transform(i,h),u=OpenLayers.Util.extend({},A);if(!k.size||isNaN(k.size))k.size=14;u.pointRadius=k.size;u.graphicOpacity=1;u.externalGraphic=k.icon;t=new OpenLayers.Feature.Vector(t,null,u);if(k.text)t.attributes={text:k.text};j.addFeatures([t])}}}}else setTimeout(function(){d()},13)};d()},start:function(s,d){f(d,"block")},end:function(s,d){f(d,"none")},_teardown:function(){q&&q.removeChild(b);b=map=e=h=i=j=p=m=null}}},{about:{name:"Popcorn OpenMap Plugin",
9
+ (function(p,e){function l(a){C.put.call(this,a)}function d(a){this.parent=a;this.byStart=[{start:-1,end:-1}];this.byEnd=[{start:-1,end:-1}];this.animating=[];this.endIndex=this.startIndex=0;this.previousUpdateTime=-1;this.count=1}function b(a,c){return function(){if(f.plugin.debug)return a.apply(this,arguments);try{return a.apply(this,arguments)}catch(n){f.plugin.errors.push({plugin:c,thrown:n,source:a.toString()});this.emit("pluginerror",f.plugin.errors)}}}if(e.addEventListener){var h=Array.prototype,
10
+ i=Object.prototype,g=h.forEach,k=h.slice,r=i.hasOwnProperty,m=i.toString,t=p.Popcorn,q=[],o=false,u={events:{hash:{},apis:{}}},E=function(){return p.requestAnimationFrame||p.webkitRequestAnimationFrame||p.mozRequestAnimationFrame||p.oRequestAnimationFrame||p.msRequestAnimationFrame||function(a){p.setTimeout(a,16)}}(),C={put:function(a){for(var c in a)if(a.hasOwnProperty(c))this[c]=a[c]}},f=function(a,c){return new f.p.init(a,c||null)};f.version="1.5.6";f.isSupported=true;f.instances=[];f.p=f.prototype=
11
+ {init:function(a,c){var n,j=this;if(typeof a==="function")if(e.readyState==="complete")a(e,f);else{q.push(a);if(!o){o=true;var w=function(){e.removeEventListener("DOMContentLoaded",w,false);for(var F=0,v=q.length;F<v;F++)q[F].call(e,f);q=null};e.addEventListener("DOMContentLoaded",w,false)}}else{if(typeof a==="string")try{n=e.querySelector(a)}catch(x){throw Error("Popcorn.js Error: Invalid media element selector: "+a);}this.media=n||a;n=this.media.nodeName&&this.media.nodeName.toLowerCase()||"video";
12
+ this[n]=this.media;this.options=f.extend({},c)||{};this.id=this.options.id||f.guid(n);if(f.byId(this.id))throw Error("Popcorn.js Error: Cannot use duplicate ID ("+this.id+")");this.isDestroyed=false;this.data={running:{cue:[]},timeUpdate:f.nop,disabled:{},events:{},hooks:{},history:[],state:{volume:this.media.volume},trackRefs:{},trackEvents:new d(this)};f.instances.push(this);var z=function(){if(j.media.currentTime<0)j.media.currentTime=0;j.media.removeEventListener("loadedmetadata",z,false);var F,
13
+ v,L,y,s;F=j.media.duration;F=F!=F?Number.MAX_VALUE:F+1;f.addTrackEvent(j,{start:F,end:F});if(!j.isDestroyed){j.data.durationChange=function(){var B=j.media.duration,Q=B+1,K=j.data.trackEvents.byStart,M=j.data.trackEvents.byEnd;K.pop();M.pop();for(var D=M.length-1;D>0;D--)M[D].end>B&&j.removeTrackEvent(M[D]._id);for(M=0;M<K.length;M++)K[M].end>B&&j.removeTrackEvent(K[M]._id);j.data.trackEvents.byEnd.push({start:Q,end:Q});j.data.trackEvents.byStart.push({start:Q,end:Q})};j.media.addEventListener("durationchange",
14
+ j.data.durationChange,false)}if(j.options.frameAnimation){j.data.timeUpdate=function(){f.timeUpdate(j,{});f.forEach(f.manifest,function(B,Q){if(v=j.data.running[Q]){y=v.length;for(var K=0;K<y;K++){L=v[K];(s=L._natives)&&s.frame&&s.frame.call(j,{},L,j.currentTime())}}});j.emit("timeupdate");!j.isDestroyed&&E(j.data.timeUpdate)};!j.isDestroyed&&E(j.data.timeUpdate)}else{j.data.timeUpdate=function(B){f.timeUpdate(j,B)};j.isDestroyed||j.media.addEventListener("timeupdate",j.data.timeUpdate,false)}};j.media.addEventListener("error",
15
+ function(){j.error=j.media.error},false);j.media.readyState>=1?z():j.media.addEventListener("loadedmetadata",z,false);return this}}};f.p.init.prototype=f.p;f.byId=function(a){for(var c=f.instances,n=c.length,j=0;j<n;j++)if(c[j].id===a)return c[j];return null};f.forEach=function(a,c,n){if(!a||!c)return{};n=n||this;var j,w;if(g&&a.forEach===g)return a.forEach(c,n);if(m.call(a)==="[object NodeList]"){j=0;for(w=a.length;j<w;j++)c.call(n,a[j],j,a);return a}for(j in a)r.call(a,j)&&c.call(n,a[j],j,a);return a};
16
+ f.extend=function(a){var c=k.call(arguments,1);f.forEach(c,function(n){for(var j in n)a[j]=n[j]});return a};f.extend(f,{noConflict:function(a){if(a)p.Popcorn=t;return f},error:function(a){throw Error(a);},guid:function(a){f.guid.counter++;return(a?a:"")+(+new Date+f.guid.counter)},sizeOf:function(a){var c=0,n;for(n in a)c++;return c},isArray:Array.isArray||function(a){return m.call(a)==="[object Array]"},nop:function(){},position:function(a){if(!a.parentNode)return null;a=a.getBoundingClientRect();
17
+ var c={},n=e.documentElement,j=e.body,w,x,z;w=n.clientTop||j.clientTop||0;x=n.clientLeft||j.clientLeft||0;z=p.pageYOffset&&n.scrollTop||j.scrollTop;n=p.pageXOffset&&n.scrollLeft||j.scrollLeft;w=Math.ceil(a.top+z-w);x=Math.ceil(a.left+n-x);for(var F in a)c[F]=Math.round(a[F]);return f.extend({},c,{top:w,left:x})},disable:function(a,c){if(!a.data.disabled[c]){a.data.disabled[c]=true;if(c in f.registryByName&&a.data.running[c])for(var n=a.data.running[c].length-1,j;n>=0;n--){j=a.data.running[c][n];j._natives.end.call(a,
18
+ null,j);a.emit("trackend",f.extend({},j,{plugin:j.type,type:"trackend"}))}return a}},enable:function(a,c){if(a.data.disabled[c]){a.data.disabled[c]=false;if(c in f.registryByName&&a.data.running[c])for(var n=a.data.running[c].length-1,j;n>=0;n--){j=a.data.running[c][n];j._natives.start.call(a,null,j);a.emit("trackstart",f.extend({},j,{plugin:j.type,type:"trackstart",track:j}))}return a}},destroy:function(a){var c=a.data.events,n=a.data.trackEvents,j,w,x,z;for(w in c){j=c[w];for(x in j)delete j[x];
19
+ c[w]=null}for(z in f.registryByName)f.removePlugin(a,z);n.byStart.length=0;n.byEnd.length=0;if(!a.isDestroyed){a.data.timeUpdate&&a.media.removeEventListener("timeupdate",a.data.timeUpdate,false);a.isDestroyed=true}f.instances.splice(f.instances.indexOf(a),1)}});f.guid.counter=1;f.extend(f.p,function(){var a={};f.forEach("load play pause currentTime playbackRate volume duration preload playbackRate autoplay loop controls muted buffered readyState seeking paused played seekable ended".split(/\s+/g),
20
+ function(c){a[c]=function(n){var j;if(typeof this.media[c]==="function"){if(n!=null&&/play|pause/.test(c))this.media.currentTime=f.util.toSeconds(n);this.media[c]();return this}if(n!=null){j=this.media[c];this.media[c]=n;j!==n&&this.emit("attrchange",{attribute:c,previousValue:j,currentValue:n});return this}return this.media[c]}});return a}());f.forEach("enable disable".split(" "),function(a){f.p[a]=function(c){return f[a](this,c)}});f.extend(f.p,{roundTime:function(){return Math.round(this.media.currentTime)},
21
+ exec:function(a,c,n){var j=arguments.length,w="trackadded",x,z;try{z=f.util.toSeconds(a)}catch(F){}if(typeof z==="number")a=z;if(typeof a==="number"&&j===2){n=c;c=a;a=f.guid("cue")}else if(j===1)c=-1;else if(x=this.getTrackEvent(a)){this.data.trackEvents.remove(a);l.end(this,x);f.removeTrackEvent.ref(this,a);w="cuechange";if(typeof a==="string"&&j===2){if(typeof c==="number")n=x._natives.start;if(typeof c==="function"){n=c;c=x.start}}}else if(j>=2){if(typeof c==="string"){try{z=f.util.toSeconds(c)}catch(v){}c=
22
+ z}if(typeof c==="number")n=n||f.nop();if(typeof c==="function"){n=c;c=-1}}j={id:a,start:c,end:c+1,_running:false,_natives:{start:n||f.nop,end:f.nop,type:"cue"}};if(x)j=f.extend(x,j);if(w==="cuechange"){j._id=j.id||j._id||f.guid(j._natives.type);this.data.trackEvents.add(j);l.start(this,j);this.timeUpdate(this,null,true);f.addTrackEvent.ref(this,j);this.emit(w,f.extend({},j,{id:a,type:w,previousValue:{time:x.start,fn:x._natives.start},currentValue:{time:c,fn:n||f.nop},track:x}))}else f.addTrackEvent(this,
23
+ j);return this},mute:function(a){a=a==null||a===true?"muted":"unmuted";if(a==="unmuted"){this.media.muted=false;this.media.volume=this.data.state.volume}if(a==="muted"){this.data.state.volume=this.media.volume;this.media.muted=true}this.emit(a);return this},unmute:function(a){return this.mute(a==null?false:!a)},position:function(){return f.position(this.media)},toggle:function(a){return f[this.data.disabled[a]?"enable":"disable"](this,a)},defaults:function(a,c){if(f.isArray(a)){f.forEach(a,function(n){for(var j in n)this.defaults(j,
24
+ n[j])},this);return this}if(!this.options.defaults)this.options.defaults={};this.options.defaults[a]||(this.options.defaults[a]={});f.extend(this.options.defaults[a],c);return this}});f.Events={UIEvents:"blur focus focusin focusout load resize scroll unload",MouseEvents:"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave click dblclick",Events:"loadstart progress suspend emptied stalled play pause error loadedmetadata loadeddata waiting playing canplay canplaythrough seeking seeked timeupdate ended ratechange durationchange volumechange"};
25
+ f.Events.Natives=f.Events.UIEvents+" "+f.Events.MouseEvents+" "+f.Events.Events;u.events.apiTypes=["UIEvents","MouseEvents","Events"];(function(a,c){for(var n=u.events.apiTypes,j=a.Natives.split(/\s+/g),w=0,x=j.length;w<x;w++)c.hash[j[w]]=true;n.forEach(function(z){c.apis[z]={};for(var F=a[z].split(/\s+/g),v=F.length,L=0;L<v;L++)c.apis[z][F[L]]=true})})(f.Events,u.events);f.events={isNative:function(a){return!!u.events.hash[a]},getInterface:function(a){if(!f.events.isNative(a))return false;var c=
26
+ u.events,n=c.apiTypes;c=c.apis;for(var j=0,w=n.length,x,z;j<w;j++){z=n[j];if(c[z][a]){x=z;break}}return x},all:f.Events.Natives.split(/\s+/g),fn:{trigger:function(a,c){var n,j=this.data.events[a];if(j){if(n=f.events.getInterface(a)){n=e.createEvent(n);n.initEvent(a,true,true,p,1);this.media.dispatchEvent(n);return this}for(n=j.slice();n.length;)n.shift().call(this,c)}return this},listen:function(a,c){var n=this,j=true,w=f.events.hooks[a],x,z;if(typeof c!=="function")throw Error("Popcorn.js Error: Listener is not a function");
27
+ if(!this.data.events[a]){this.data.events[a]=[];j=false}if(w){w.add&&w.add.call(this,{},c);if(w.bind)a=w.bind;if(w.handler){z=c;c=function(F){w.handler.call(n,F,z)}}j=true;if(!this.data.events[a]){this.data.events[a]=[];j=false}}this.data.events[a].push(c);!j&&f.events.all.indexOf(a)>-1&&this.media.addEventListener(a,function(F){if(n.data.events[a])for(x=n.data.events[a].slice();x.length;)x.shift().call(n,F)},false);return this},unlisten:function(a,c){var n,j=this.data.events[a];if(j){if(typeof c===
28
+ "string"){for(n=0;n<j.length;n++)j[n].name===c&&j.splice(n--,1);return this}else if(typeof c==="function"){for(;n!==-1;){n=j.indexOf(c);n!==-1&&j.splice(n,1)}return this}this.data.events[a]=null;return this}}},hooks:{canplayall:{bind:"canplaythrough",add:function(a,c){var n=false;if(this.media.readyState){setTimeout(function(){c.call(this,a)}.bind(this),0);n=true}this.data.hooks.canplayall={fired:n}},handler:function(a,c){if(!this.data.hooks.canplayall.fired){c.call(this,a);this.data.hooks.canplayall.fired=
29
+ true}}}}};f.forEach([["trigger","emit"],["listen","on"],["unlisten","off"]],function(a){f.p[a[0]]=f.p[a[1]]=f.events.fn[a[0]]});l.start=function(a,c){if(c.end>a.media.currentTime&&c.start<=a.media.currentTime&&!c._running){c._running=true;a.data.running[c._natives.type].push(c);if(!a.data.disabled[c._natives.type]){c._natives.start.call(a,null,c);a.emit("trackstart",f.extend({},c,{plugin:c._natives.type,type:"trackstart",track:c}))}}};l.end=function(a,c){var n;if((c.end<=a.media.currentTime||c.start>
30
+ a.media.currentTime)&&c._running){n=a.data.running[c._natives.type];c._running=false;n.splice(n.indexOf(c),1);if(!a.data.disabled[c._natives.type]){c._natives.end.call(a,null,c);a.emit("trackend",f.extend({},c,{plugin:c._natives.type,type:"trackend",track:c}))}}};d.prototype.where=function(a){return(this.parent.getTrackEvents()||[]).filter(function(c){var n,j;if(!a)return true;for(n in a){j=a[n];if(c[n]&&c[n]===j||c._natives[n]&&c._natives[n]===j)return true}return false})};d.prototype.add=function(a){var c=
31
+ this.byStart,n=this.byEnd,j;a&&a._id&&this.parent.data.history.push(a._id);a.start=f.util.toSeconds(a.start,this.parent.options.framerate);a.end=f.util.toSeconds(a.end,this.parent.options.framerate);for(j=c.length-1;j>=0;j--)if(a.start>=c[j].start){c.splice(j+1,0,a);break}for(c=n.length-1;c>=0;c--)if(a.end>n[c].end){n.splice(c+1,0,a);break}j<=this.parent.data.trackEvents.startIndex&&a.start<=this.parent.data.trackEvents.previousUpdateTime&&this.parent.data.trackEvents.startIndex++;c<=this.parent.data.trackEvents.endIndex&&
32
+ a.end<this.parent.data.trackEvents.previousUpdateTime&&this.parent.data.trackEvents.endIndex++;this.count++};d.prototype.remove=function(a){if(a instanceof l)a=a.id;if(typeof a==="object"){this.where(a).forEach(function(y){this.removeTrackEvent(y._id)},this.parent);return this}var c,n,j;j=this.byStart.length;for(var w=0,x=0,z=[],F=[],v=[],L=[];--j>-1;){c=this.byStart[w];n=this.byEnd[w];if(!c._id){z.push(c);F.push(n)}if(c._id){c._id!==a&&z.push(c);n._id!==a&&F.push(n);if(c._id===a)x=w}w++}j=this.animating.length;
33
+ w=0;if(j)for(;--j>-1;){c=this.animating[w];c._id||v.push(c);c._id&&c._id!==a&&v.push(c);w++}x<=this.startIndex&&this.startIndex--;x<=this.endIndex&&this.endIndex--;this.byStart=z;this.byEnd=F;this.animating=v;this.count--;j=this.parent.data.history.length;for(w=0;w<j;w++)this.parent.data.history[w]!==a&&L.push(this.parent.data.history[w]);this.parent.data.history=L};f.addTrackEvent=function(a,c){var n;if(!(c instanceof l)){if((c=new l(c))&&c._natives&&c._natives.type&&a.options.defaults&&a.options.defaults[c._natives.type]){n=
34
+ f.extend({},c);f.extend(c,a.options.defaults[c._natives.type],n)}if(c._natives){c._id=c.id||c._id||f.guid(c._natives.type);if(c._natives._setup){c._natives._setup.call(a,c);a.emit("tracksetup",f.extend({},c,{plugin:c._natives.type,type:"tracksetup",track:c}))}}a.data.trackEvents.add(c);l.start(a,c);this.timeUpdate(a,null,true);c._id&&f.addTrackEvent.ref(a,c);a.emit("trackadded",f.extend({},c,c._natives?{plugin:c._natives.type}:{},{type:"trackadded",track:c}))}};f.addTrackEvent.ref=function(a,c){a.data.trackRefs[c._id]=
35
+ c;return a};f.removeTrackEvent=function(a,c){var n=a.getTrackEvent(c);if(n){n._natives._teardown&&n._natives._teardown.call(a,n);a.data.trackEvents.remove(c);f.removeTrackEvent.ref(a,c);n._natives&&a.emit("trackremoved",f.extend({},n,{plugin:n._natives.type,type:"trackremoved",track:n}))}};f.removeTrackEvent.ref=function(a,c){delete a.data.trackRefs[c];return a};f.getTrackEvents=function(a){var c=[];a=a.data.trackEvents.byStart;for(var n=a.length,j=0,w;j<n;j++){w=a[j];w._id&&c.push(w)}return c};f.getTrackEvents.ref=
36
+ function(a){return a.data.trackRefs};f.getTrackEvent=function(a,c){return a.data.trackRefs[c]};f.getTrackEvent.ref=function(a,c){return a.data.trackRefs[c]};f.getLastTrackEventId=function(a){return a.data.history[a.data.history.length-1]};f.timeUpdate=function(a,c){var n=a.media.currentTime,j=a.data.trackEvents.previousUpdateTime,w=a.data.trackEvents,x=w.endIndex,z=w.startIndex,F=w.byStart.length,v=w.byEnd.length,L=f.registryByName,y,s,B;if(j<=n){for(;w.byEnd[x]&&w.byEnd[x].end<=n;){y=w.byEnd[x];
37
+ s=(j=y._natives)&&j.type;if(!j||L[s]||a[s]){if(y._running===true){y._running=false;B=a.data.running[s];B.splice(B.indexOf(y),1);if(!a.data.disabled[s]){j.end.call(a,c,y);a.emit("trackend",f.extend({},y,{plugin:s,type:"trackend",track:y}))}}x++}else{f.removeTrackEvent(a,y._id);return}}for(;w.byStart[z]&&w.byStart[z].start<=n;){y=w.byStart[z];s=(j=y._natives)&&j.type;if(!j||L[s]||a[s]){if(y.end>n&&y._running===false){y._running=true;a.data.running[s].push(y);if(!a.data.disabled[s]){j.start.call(a,c,
38
+ y);a.emit("trackstart",f.extend({},y,{plugin:s,type:"trackstart",track:y}))}}z++}else{f.removeTrackEvent(a,y._id);return}}}else if(j>n){for(;w.byStart[z]&&w.byStart[z].start>n;){y=w.byStart[z];s=(j=y._natives)&&j.type;if(!j||L[s]||a[s]){if(y._running===true){y._running=false;B=a.data.running[s];B.splice(B.indexOf(y),1);if(!a.data.disabled[s]){j.end.call(a,c,y);a.emit("trackend",f.extend({},y,{plugin:s,type:"trackend",track:y}))}}z--}else{f.removeTrackEvent(a,y._id);return}}for(;w.byEnd[x]&&w.byEnd[x].end>
39
+ n;){y=w.byEnd[x];s=(j=y._natives)&&j.type;if(!j||L[s]||a[s]){if(y.start<=n&&y._running===false){y._running=true;a.data.running[s].push(y);if(!a.data.disabled[s]){j.start.call(a,c,y);a.emit("trackstart",f.extend({},y,{plugin:s,type:"trackstart",track:y}))}}x--}else{f.removeTrackEvent(a,y._id);return}}}w.endIndex=x;w.startIndex=z;w.previousUpdateTime=n;w.byStart.length<F&&w.startIndex--;w.byEnd.length<v&&w.endIndex--};f.extend(f.p,{getTrackEvents:function(){return f.getTrackEvents.call(null,this)},
40
+ getTrackEvent:function(a){return f.getTrackEvent.call(null,this,a)},getLastTrackEventId:function(){return f.getLastTrackEventId.call(null,this)},removeTrackEvent:function(a){f.removeTrackEvent.call(null,this,a);return this},removePlugin:function(a){f.removePlugin.call(null,this,a);return this},timeUpdate:function(a){f.timeUpdate.call(null,this,a);return this},destroy:function(){f.destroy.call(null,this);return this}});f.manifest={};f.registry=[];f.registryByName={};f.plugin=function(a,c,n){if(f.protect.natives.indexOf(a.toLowerCase())>=
41
+ 0)f.error("'"+a+"' is a protected function name");else{var j=typeof c==="function",w=["start","end","type","manifest"],x=["_setup","_teardown","start","end","frame"],z={},F=function(y,s){y=y||f.nop;s=s||f.nop;return function(){y.apply(this,arguments);s.apply(this,arguments)}};f.manifest[a]=n=n||c.manifest||{};x.forEach(function(y){c[y]=b(c[y]||f.nop,a)});var v=function(y,s){if(!s)return this;if(s.ranges&&f.isArray(s.ranges)){f.forEach(s.ranges,function(M){M=f.extend({},s,M);delete M.ranges;this[a](M)},
42
+ this);return this}var B=s._natives={},Q="",K;f.extend(B,y);s._natives.type=s._natives.plugin=a;s._running=false;B.start=B.start||B["in"];B.end=B.end||B.out;if(s.once)B.end=F(B.end,function(){this.removeTrackEvent(s._id)});B._teardown=F(function(){var M=k.call(arguments),D=this.data.running[B.type];M.unshift(null);M[1]._running&&D.splice(D.indexOf(s),1)&&B.end.apply(this,M);M[1]._running=false;this.emit("trackend",f.extend({},s,{plugin:B.type,type:"trackend",track:f.getTrackEvent(this,s.id||s._id)}))},
43
+ B._teardown);B._teardown=F(B._teardown,function(){this.emit("trackteardown",f.extend({},s,{plugin:a,type:"trackteardown",track:f.getTrackEvent(this,s.id||s._id)}))});s.compose=s.compose||[];if(typeof s.compose==="string")s.compose=s.compose.split(" ");s.effect=s.effect||[];if(typeof s.effect==="string")s.effect=s.effect.split(" ");s.compose=s.compose.concat(s.effect);s.compose.forEach(function(M){Q=f.compositions[M]||{};x.forEach(function(D){B[D]=F(B[D],Q[D])})});s._natives.manifest=n;if(!("start"in
44
+ s))s.start=s["in"]||0;if(!s.end&&s.end!==0)s.end=s.out||Number.MAX_VALUE;if(!r.call(s,"toString"))s.toString=function(){var M=["start: "+s.start,"end: "+s.end,"id: "+(s.id||s._id)];s.target!=null&&M.push("target: "+s.target);return a+" ( "+M.join(", ")+" )"};if(!s.target){K="options"in n&&n.options;s.target=K&&"target"in K&&K.target}if(!s._id&&s._natives)s._id=f.guid(s._natives.type);if(s instanceof l){if(s._natives){s._id=s.id||s._id||f.guid(s._natives.type);if(s._natives._setup){s._natives._setup.call(this,
45
+ s);this.emit("tracksetup",f.extend({},s,{plugin:s._natives.type,type:"tracksetup",track:s}))}}this.data.trackEvents.add(s);l.start(this,s);this.timeUpdate(this,null,true);s._id&&f.addTrackEvent.ref(this,s)}else f.addTrackEvent(this,s);f.forEach(y,function(M,D){w.indexOf(D)===-1&&this.on(D,M)},this);return this};f.p[a]=z[a]=function(y,s){var B,Q;if(y&&!s)s=y;else if(B=this.getTrackEvent(y)){Q=s;var K={},M;for(M in B)if(r.call(Q,M)&&r.call(B,M))K[M]=B[M];if(B._natives._update){this.data.trackEvents.remove(B);
46
+ if(r.call(s,"start"))B.start=s.start;if(r.call(s,"end"))B.end=s.end;l.end(this,B);j&&c.call(this,B);B._natives._update.call(this,B,s);this.data.trackEvents.add(B);l.start(this,B)}else{f.extend(B,s);this.data.trackEvents.remove(y);B._natives._teardown&&B._natives._teardown.call(this,B);f.removeTrackEvent.ref(this,y);if(j)v.call(this,c.call(this,B),B);else{B._id=B.id||B._id||f.guid(B._natives.type);if(B._natives&&B._natives._setup){B._natives._setup.call(this,B);this.emit("tracksetup",f.extend({},B,
47
+ {plugin:B._natives.type,type:"tracksetup",track:B}))}this.data.trackEvents.add(B);l.start(this,B);this.timeUpdate(this,null,true);f.addTrackEvent.ref(this,B)}this.emit("trackchange",{id:B.id,type:"trackchange",previousValue:K,currentValue:B,track:B});return this}B._natives.type!=="cue"&&this.emit("trackchange",{id:B.id,type:"trackchange",previousValue:K,currentValue:Q,track:B});return this}else s.id=y;this.data.running[a]=this.data.running[a]||[];B=f.extend({},this.options.defaults&&this.options.defaults[a]||
48
+ {},s);v.call(this,j?c.call(this,B):c,B);return this};n&&f.extend(c,{manifest:n});var L={fn:z[a],definition:c,base:c,parents:[],name:a};f.registry.push(f.extend(z,L,{type:a}));f.registryByName[a]=L;return z}};f.plugin.errors=[];f.plugin.debug=f.version==="1.5.6";f.removePlugin=function(a,c){if(!c){c=a;a=f.p;if(f.protect.natives.indexOf(c.toLowerCase())>=0){f.error("'"+c+"' is a protected function name");return}var n=f.registry.length,j;for(j=0;j<n;j++)if(f.registry[j].name===c){f.registry.splice(j,
49
+ 1);delete f.registryByName[c];delete f.manifest[c];delete a[c];return}}n=a.data.trackEvents.byStart;j=a.data.trackEvents.byEnd;var w=a.data.trackEvents.animating,x,z;x=0;for(z=n.length;x<z;x++){if(n[x]&&n[x]._natives&&n[x]._natives.type===c){n[x]._natives._teardown&&n[x]._natives._teardown.call(a,n[x]);n.splice(x,1);x--;z--;if(a.data.trackEvents.startIndex<=x){a.data.trackEvents.startIndex--;a.data.trackEvents.endIndex--}}j[x]&&j[x]._natives&&j[x]._natives.type===c&&j.splice(x,1)}x=0;for(z=w.length;x<
50
+ z;x++)if(w[x]&&w[x]._natives&&w[x]._natives.type===c){w.splice(x,1);x--;z--}};f.compositions={};f.compose=function(a,c,n){f.manifest[a]=n||c.manifest||{};f.compositions[a]=c};f.plugin.effect=f.effect=f.compose;var G=/^(?:\.|#|\[)/;f.dom={debug:false,find:function(a,c){var n=null;c=c||e;if(a){if(!G.test(a)){n=e.getElementById(a);if(n!==null)return n}try{n=c.querySelector(a)}catch(j){if(f.dom.debug)throw Error(j);}}return n}};var A=/\?/,O={ajax:null,url:"",data:"",dataType:"",success:f.nop,type:"GET",
51
+ async:true,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};f.xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;if(a.dataType&&(a.dataType==="jsonp"||a.dataType==="script"))f.xhr.getJSONP(a.url,a.success,a.dataType==="script");else{a=f.extend({},O,a);a.ajax=new XMLHttpRequest;if(a.ajax){if(a.type==="GET"&&a.data){a.url+=(A.test(a.url)?"&":"?")+a.data;a.data=null}a.ajax.open(a.type,a.url,a.async);a.type==="POST"&&a.ajax.setRequestHeader("Content-Type",a.contentType);
52
+ a.ajax.send(a.data||null);return f.xhr.httpData(a)}}};f.xhr.httpData=function(a){var c,n=null,j,w=null;a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{n=JSON.parse(a.ajax.responseText)}catch(x){}c={xml:a.ajax.responseXML,text:a.ajax.responseText,json:n};if(!c.xml||!c.xml.documentElement){c.xml=null;try{j=new DOMParser;w=j.parseFromString(a.ajax.responseText,"text/xml");if(!w.getElementsByTagName("parsererror").length)c.xml=w}catch(z){}}if(a.dataType)c=c[a.dataType];a.success.call(a.ajax,
53
+ c)}};return c};f.xhr.getJSONP=function(a,c,n){var j=e.head||e.getElementsByTagName("head")[0]||e.documentElement,w=e.createElement("script"),x=false,z=[];z=/(=)\?(?=&|$)|\?\?/;var F,v;if(!n){v=a.match(/(callback=[^&]*)/);if(v!==null&&v.length){z=v[1].split("=")[1];if(z==="?")z="jsonp";F=f.guid(z);a=a.replace(/(callback=[^&]*)/,"callback="+F)}else{F=f.guid("jsonp");if(z.test(a))a=a.replace(z,"$1"+F);z=a.split(/\?(.+)?/);a=z[0]+"?";if(z[1])a+=z[1]+"&";a+="callback="+F}window[F]=function(L){c&&c(L);
54
+ x=true}}w.addEventListener("load",function(){n&&c&&c();x&&delete window[F];j.removeChild(w)},false);w.addEventListener("error",function(L){c&&c({error:L});n||delete window[F];j.removeChild(w)},false);w.src=a;j.insertBefore(w,j.firstChild)};f.getJSONP=f.xhr.getJSONP;f.getScript=f.xhr.getScript=function(a,c){return f.xhr.getJSONP(a,c,true)};f.util={toSeconds:function(a,c){var n=/^([0-9]+:){0,2}[0-9]+([.;][0-9]+)?$/,j,w,x;if(typeof a==="number")return a;typeof a==="string"&&!n.test(a)&&f.error("Invalid time format");
55
+ n=a.split(":");j=n.length-1;w=n[j];if(w.indexOf(";")>-1){w=w.split(";");x=0;if(c&&typeof c==="number")x=parseFloat(w[1],10)/c;n[j]=parseInt(w[0],10)+x}j=n[0];return{1:parseFloat(j,10),2:parseInt(j,10)*60+parseFloat(n[1],10),3:parseInt(j,10)*3600+parseInt(n[1],10)*60+parseFloat(n[2],10)}[n.length||1]}};f.p.cue=f.p.exec;f.protect={natives:function(a){return Object.keys?Object.keys(a):function(c){var n,j=[];for(n in c)r.call(c,n)&&j.push(n);return j}(a)}(f.p).map(function(a){return a.toLowerCase()})};
56
+ f.forEach({listen:"on",unlisten:"off",trigger:"emit",exec:"cue"},function(a,c){var n=f.p[c];f.p[c]=function(){if(typeof console!=="undefined"&&console.warn){console.warn("Deprecated method '"+c+"', "+(a==null?"do not use.":"use '"+a+"' instead."));f.p[c]=n}return f.p[a].apply(this,[].slice.call(arguments))}});p.Popcorn=f}else{p.Popcorn={isSupported:false};for(h="byId forEach extend effects error guid sizeOf isArray nop position disable enable destroyaddTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId timeUpdate plugin removePlugin compose effect xhr getJSONP getScript".split(/\s+/);h.length;)p.Popcorn[h.shift()]=
57
+ function(){}}})(window,window.document);(function(p,e){var l=p.document,d=p.location,b=/:\/\//,h=d.href.replace(d.href.split("/").slice(-1)[0],""),i=function(k,r,m){k=k||0;r=(r||k||0)+1;m=m||1;r=Math.ceil((r-k)/m)||0;var t=0,q=[];for(q.length=r;t<r;){q[t++]=k;k+=m}return q};e.sequence=function(k,r){return new e.sequence.init(k,r)};e.sequence.init=function(k,r){this.parent=l.getElementById(k);this.seqId=e.guid("__sequenced");this.queue=[];this.playlist=[];this.inOuts={ofVideos:[],ofClips:[]};this.dims={width:0,height:0};this.active=0;this.playing=
58
+ this.cycling=false;this.times={last:0};this.events={};var m=this,t=0;e.forEach(r,function(q,o){var u=l.createElement("video");u.preload="auto";u.controls=true;u.style.display=o&&"none"||"";u.id=m.seqId+"-"+o;m.queue.push(u);var E=q["in"],C=q.out;m.inOuts.ofVideos.push({"in":E!==undefined&&E||1,out:C!==undefined&&C||0});m.inOuts.ofVideos[o].out=m.inOuts.ofVideos[o].out||m.inOuts.ofVideos[o]["in"]+2;u.src=!b.test(q.src)?h+q.src:q.src;u.setAttribute("data-sequence-owner",k);u.setAttribute("data-sequence-guid",
59
+ m.seqId);u.setAttribute("data-sequence-id",o);u.setAttribute("data-sequence-clip",[m.inOuts.ofVideos[o]["in"],m.inOuts.ofVideos[o].out].join(":"));m.parent.appendChild(u);m.playlist.push(e("#"+u.id))});m.inOuts.ofVideos.forEach(function(q){q={"in":t,out:t+(q.out-q["in"])};m.inOuts.ofClips.push(q);t=q.out+1});e.forEach(this.queue,function(q,o){function u(){if(!o){m.dims.width=q.videoWidth;m.dims.height=q.videoHeight}q.currentTime=m.inOuts.ofVideos[o]["in"]-0.5;q.removeEventListener("canplaythrough",
60
+ u,false);return true}q.addEventListener("canplaythrough",u,false);q.addEventListener("play",function(){m.playing=true},false);q.addEventListener("pause",function(){m.playing=false},false);q.addEventListener("timeupdate",function(E){E=E.srcElement||E.target;E=+(E.dataset&&E.dataset.sequenceId||E.getAttribute("data-sequence-id"));var C=Math.floor(q.currentTime);if(m.times.last!==C&&E===m.active){m.times.last=C;C===m.inOuts.ofVideos[E].out&&e.sequence.cycle.call(m,E)}},false)});return this};e.sequence.init.prototype=
61
+ e.sequence.prototype;e.sequence.cycle=function(k){this.queue||e.error("Popcorn.sequence.cycle is not a public method");var r=this.queue,m=this.inOuts.ofVideos,t=r[k],q=0,o;if(r[k+1])q=k+1;if(r[k+1]){r=r[q];m=m[q];e.extend(r,{width:this.dims.width,height:this.dims.height});o=this.playlist[q];t.pause();this.active=q;this.times.last=m["in"]-1;o.currentTime(m["in"]);o[q?"play":"pause"]();this.trigger("cycle",{position:{previous:k,current:q}});if(q){t.style.display="none";r.style.display=""}this.cycling=
62
+ false}else this.playlist[k].pause();return this};var g=["timeupdate","play","pause"];e.extend(e.sequence.prototype,{eq:function(k){return this.playlist[k]},remove:function(){this.parent.innerHTML=null},clip:function(k){return this.inOuts.ofVideos[k]},duration:function(){for(var k=0,r=this.inOuts.ofClips,m=0;m<r.length;m++)k+=r[m].out-r[m]["in"]+1;return k-1},play:function(){this.playlist[this.active].play();return this},exec:function(k,r){var m=this.active;this.inOuts.ofClips.forEach(function(t,q){if(k>=
63
+ t["in"]&&k<=t.out)m=q});k+=this.inOuts.ofVideos[m]["in"]-this.inOuts.ofClips[m]["in"];e.addTrackEvent(this.playlist[m],{start:k-1,end:k,_running:false,_natives:{start:r||e.nop,end:e.nop,type:"exec"}});return this},listen:function(k,r){var m=this,t=this.playlist,q=t.length,o=0;if(!r)r=e.nop;if(e.Events.Natives.indexOf(k)>-1)e.forEach(t,function(u){u.listen(k,function(E){E.active=m;if(g.indexOf(k)>-1)r.call(u,E);else++o===q&&r.call(u,E)})});else{this.events[k]||(this.events[k]={});t=r.name||e.guid("__"+
64
+ k);this.events[k][t]=r}return this},unlisten:function(){},trigger:function(k,r){var m=this;if(!(e.Events.Natives.indexOf(k)>-1)){this.events[k]&&e.forEach(this.events[k],function(t){t.call(m,{type:k},r)});return this}}});e.forEach(e.manifest,function(k,r){e.sequence.prototype[r]=function(m){var t={},q=[],o,u,E,C,f;for(o=0;o<this.inOuts.ofClips.length;o++){q=this.inOuts.ofClips[o];u=i(q["in"],q.out);E=u.indexOf(m.start);C=u.indexOf(m.end);if(E>-1)t[o]=e.extend({},q,{start:u[E],clipIdx:E});if(C>-1)t[o]=
65
+ e.extend({},q,{end:u[C],clipIdx:C})}o=Object.keys(t).map(function(A){return+A});q=i(o[0],o[1]);for(o=0;o<q.length;o++){E={};C=q[o];var G=t[C];if(G){f=this.inOuts.ofVideos[C];u=G.clipIdx;f=i(f["in"],f.out);if(G.start){E.start=f[u];E.end=f[f.length-1]}if(G.end){E.start=f[0];E.end=f[u]}}else{E.start=this.inOuts.ofVideos[C]["in"];E.end=this.inOuts.ofVideos[C].out}this.playlist[C][r](e.extend({},m,E))}return this}})})(this,Popcorn);(function(p,e){function l(h){h=typeof h==="string"?h:[h.language,h.region].join("-");var i=h.split("-");return{iso6391:h,language:i[0]||"",region:i[1]||""}}var d=p.navigator,b=l(d.userLanguage||d.language);e.locale={get:function(){return b},set:function(h){b=l(h);e.locale.broadcast();return b},broadcast:function(h){var i=e.instances,g=i.length,k=0,r;for(h=h||"locale:changed";k<g;k++){r=i[k];h in r.data.events&&r.trigger(h)}}}})(this,this.Popcorn);(function(p){document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-timeline-sources]");p.forEach(e,function(l,d){var b=e[d],h,i,g;if(!b.id)b.id=p.guid("__popcorn");if(b.nodeType&&b.nodeType===1){g=p("#"+b.id);h=(b.getAttribute("data-timeline-sources")||"").split(",");h[0]&&p.forEach(h,function(k){i=k.split("!");if(i.length===1){i=k.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/)[2].split(".");i[0]="parse"+i[1].toUpperCase();i[1]=k}h[0]&&g[i[0]]&&g[i[0]](i[1])});g.autoplay()&&
66
+ g.play()}})},false)})(Popcorn);(function(p){var e=function(l,d){l=l||p.nop;d=d||p.nop;return function(){l.apply(this,arguments);d.apply(this,arguments)}};p.player=function(l,d){if(!p[l]){d=d||{};var b=function(h,i,g){g=g||{};var k=new Date/1E3,r=k,m=0,t=0,q=1,o=false,u={},E=typeof h==="string"?p.dom.find(h):h,C={};Object.prototype.__defineGetter__||(C=E||document.createElement("div"));for(var f in E)if(!(f in C))if(typeof E[f]==="object")C[f]=E[f];else if(typeof E[f]==="function")C[f]=function(A){return"length"in E[A]&&!E[A].call?
67
+ E[A]:function(){return E[A].apply(E,arguments)}}(f);else p.player.defineProperty(C,f,{get:function(A){return function(){return E[A]}}(f),set:p.nop,configurable:true});var G=function(){k=new Date/1E3;if(!C.paused){C.currentTime+=k-r;C.dispatchEvent("timeupdate");setTimeout(G,10)}r=k};C.play=function(){this.paused=false;if(C.readyState>=4){r=new Date/1E3;C.dispatchEvent("play");G()}};C.pause=function(){this.paused=true;C.dispatchEvent("pause")};p.player.defineProperty(C,"currentTime",{get:function(){return m},
68
+ set:function(A){m=+A;C.dispatchEvent("timeupdate");return m},configurable:true});p.player.defineProperty(C,"volume",{get:function(){return q},set:function(A){q=+A;C.dispatchEvent("volumechange");return q},configurable:true});p.player.defineProperty(C,"muted",{get:function(){return o},set:function(A){o=+A;C.dispatchEvent("volumechange");return o},configurable:true});p.player.defineProperty(C,"readyState",{get:function(){return t},set:function(A){return t=A},configurable:true});C.addEventListener=function(A,
69
+ O){u[A]||(u[A]=[]);u[A].push(O);return O};C.removeEventListener=function(A,O){var a,c=u[A];if(c){for(a=u[A].length-1;a>=0;a--)O===c[a]&&c.splice(a,1);return O}};C.dispatchEvent=function(A){var O,a=A.type;if(!a){a=A;if(A=p.events.getInterface(a)){O=document.createEvent(A);O.initEvent(a,true,true,window,1)}}if(u[a])for(A=u[a].length-1;A>=0;A--)u[a][A].call(this,O,this)};C.src=i||"";C.duration=0;C.paused=true;C.ended=0;g&&g.events&&p.forEach(g.events,function(A,O){C.addEventListener(O,A,false)});if(d._canPlayType(E.nodeName,
70
+ i)!==false)if(d._setup)d._setup.call(C,g);else{C.readyState=4;C.dispatchEvent("loadedmetadata");C.dispatchEvent("loadeddata");C.dispatchEvent("canplaythrough")}else setTimeout(function(){C.dispatchEvent("error")},0);h=new p.p.init(C,g);if(d._teardown)h.destroy=e(h.destroy,function(){d._teardown.call(C,g)});return h};b.canPlayType=d._canPlayType=d._canPlayType||p.nop;p[l]=p.player.registry[l]=b}};p.player.registry={};p.player.defineProperty=Object.defineProperty||function(l,d,b){l.__defineGetter__(d,
71
+ b.get||p.nop);l.__defineSetter__(d,b.set||p.nop)};p.player.playerQueue=function(){var l=[],d=false;return{next:function(){d=false;l.shift();l[0]&&l[0]()},add:function(b){l.push(function(){d=true;b&&b()});!d&&l[0]()}}};p.smart=function(l,d,b){var h=typeof l==="string"?p.dom.find(l):l,i,g,k,r,m,t="HTMLYouTubeVideoElement HTMLVimeoVideoElement HTMLSoundCloudAudioElement HTMLNullVideoElement".split(" ");if(h){d=typeof d==="string"?[d]:d;l=0;for(m=d.length;l<m;l++){i=d[l];for(g=0;g<t.length;g++)if((r=
72
+ p[t[g]])&&r._canPlaySrc(i)==="probably"){k=r(h);b=p(k,b);setTimeout(function(){k.src=i},0);return b}for(var q in p.player.registry)if(p.player.registry.hasOwnProperty(q))if(p.player.registry[q].canPlayType(h.nodeName,i))return p[q](h,i,b)}var o;q=p.guid("popcorn-video-");g=document.createElement("div");g.style.width="100%";g.style.height="100%";if(d.length===1){o=document.createElement("video");o.id=q;h.appendChild(o);setTimeout(function(){var u=document.createElement("div");u.innerHTML=d[0];o.src=
73
+ u.firstChild.nodeValue},0);return p("#"+q,b)}h.appendChild(g);t='<video id="'+q+'" preload=auto autobuffer>';l=0;for(m=d.length;l<m;l++)t+='<source src="'+d[l]+'">';t+="</video>";g.innerHTML=t;b&&b.events&&b.events.error&&h.addEventListener("error",b.events.error,false);return p("#"+q,b)}else p.error("Specified target `"+l+"` was not found.")}})(Popcorn);(function(p){var e=Object.prototype.hasOwnProperty;p.parsers={};p.parser=function(l,d,b){if(p.protect.natives.indexOf(l.toLowerCase())>=0)p.error("'"+l+"' is a protected function name");else{if(typeof d==="function"&&!b){b=d;d=""}if(!(typeof b!=="function"||typeof d!=="string")){var h={};h[l]=function(i,g,k){if(!i)return this;if(typeof g!=="function"&&!k){k=g;g=null}var r=this;p.xhr({url:i,dataType:d,success:function(m){var t,q,o=0;m=b(m,k).data||[];if(t=m.length){for(;o<t;o++){q=m[o];for(var u in q)e.call(q,
74
+ u)&&r[u]&&r[u](q[u])}g&&g()}}});return this};p.extend(p.p,h);return h}}}})(Popcorn);(function(p,e){function l(b){var h=l.options;b=h.parser[h.strictMode?"strict":"loose"].exec(b);for(var i={},g=14;g--;)i[h.key[g]]=b[g]||"";i[h.q.name]={};i[h.key[12]].replace(h.q.parser,function(k,r,m){if(r)i[h.q.name][r]=m});return i}l.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
75
+ loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var d={length:0,start:p.nop,end:p.nop};window.MediaError=window.MediaError||function(){function b(h,i){this.code=h||null;this.message=i||""}b.MEDIA_ERR_NONE_ACTIVE=0;b.MEDIA_ERR_ABORTED=1;b.MEDIA_ERR_NETWORK=2;b.MEDIA_ERR_DECODE=3;b.MEDIA_ERR_NONE_SUPPORTED=4;return b}();p._MediaElementProto=function(){var b=
76
+ {},h;Object.prototype.__defineGetter__||(b=e.createElement("div"));b._util={type:"HTML5",TIMEUPDATE_MS:250,MIN_WIDTH:300,MIN_HEIGHT:150,isAttributeSet:function(i){return typeof i==="string"||i===true},parseUri:l};b.addEventListener=function(i,g,k){e.addEventListener(this._eventNamespace+i,g,k)};b.removeEventListener=function(i,g,k){e.removeEventListener(this._eventNamespace+i,g,k)};b.dispatchEvent=function(i){var g=e.createEvent("CustomEvent");g.initCustomEvent(this._eventNamespace+i,false,false,
77
+ {type:i,target:this.parentNode,data:null});e.dispatchEvent(g)};b.load=p.nop;b.canPlayType=function(){return""};b.getBoundingClientRect=function(){return h.getBoundingClientRect()};b.NETWORK_EMPTY=0;b.NETWORK_IDLE=1;b.NETWORK_LOADING=2;b.NETWORK_NO_SOURCE=3;b.HAVE_NOTHING=0;b.HAVE_METADATA=1;b.HAVE_CURRENT_DATA=2;b.HAVE_FUTURE_DATA=3;b.HAVE_ENOUGH_DATA=4;Object.defineProperties(b,{currentSrc:{get:function(){return this.src!==undefined?this.src:""},configurable:true},parentNode:{get:function(){return h},
78
+ set:function(i){h=i},configurable:true},preload:{get:function(){return"auto"},set:p.nop,configurable:true},controls:{get:function(){return true},set:p.nop,configurable:true},poster:{get:function(){return""},set:p.nop,configurable:true},crossorigin:{get:function(){return""},configurable:true},played:{get:function(){return d},configurable:true},seekable:{get:function(){return d},configurable:true},buffered:{get:function(){return d},configurable:true},defaultMuted:{get:function(){return false},configurable:true},
79
+ defaultPlaybackRate:{get:function(){return 1},configurable:true},style:{get:function(){return this.parentNode.style},configurable:true},id:{get:function(){return this.parentNode.id},configurable:true}});return b}})(Popcorn,window.document);(function(p,e,l){function d(){if(e.jwplayer){k=true;for(var t=m.length;t--;){m[t]();delete m[t]}}else setTimeout(d,100)}function b(){if(!r){if(!e.jwplayer){var t=l.createElement("script");t.src="https://jwpsrv.com/library/zaIF4JI9EeK2FSIACpYGxA.js";var q=l.getElementsByTagName("script")[0];q.parentNode.insertBefore(t,q)}r=true;d()}return k}function h(t){m.unshift(t)}function i(t){function q(P){D.unshift(P)}function o(){setTimeout(function(){v.duration=K.getDuration();z.dispatchEvent("durationchange");
80
+ v.readyState=z.HAVE_METADATA;z.dispatchEvent("loadedmetadata");z.dispatchEvent("loadeddata");v.readyState=z.HAVE_FUTURE_DATA;z.dispatchEvent("canplay");for(B=true;D.length;){D[0]();D.shift()}v.readyState=z.HAVE_ENOUGH_DATA;z.dispatchEvent("canplaythrough")},0)}function u(){if(y)y=false;else if(I){I=false;o()}else n()}function E(){if(v.seeking){v.ended=false;v.seeking=false;z.dispatchEvent("timeupdate");z.dispatchEvent("seeked");z.dispatchEvent("canplay");z.dispatchEvent("canplaythrough")}}function C(){K.onPause(u);
81
+ K.onTime(function(){if(!v.ended&&!v.seeking){v.currentTime=K.getPosition();z.dispatchEvent("timeupdate")}});K.onSeek(E);K.onPlay(function(){if(!v.ended)if(T){T=false;if(v.autoplay||!v.paused){v.paused=false;q(a);o()}else{s=I=true;K.pause(true)}}else if(s){s=false;y=true;K.pause(true)}else a()});K.onBufferChange(c);K.onComplete(j);K.play(true)}function f(P){var S={name:"MediaError"};S.message=P.message;S.code=P.code||5;v.error=S;z.dispatchEvent("error")}function G(P){if(z._canPlaySrc(P)){var S=z._util.parseUri(P).queryKey;
82
+ v.controls=S.controls=S.controls||v.controls;v.src=P;if(b()){if(L)L&&K&&K.destroy();jwplayer(F.id).setup({file:P,width:"100%",height:"100%",controls:v.controls});K=jwplayer(F.id);K.onReady(C);K.onError(f);jwplayer.utils.log=function(H,V){if(typeof console!=="undefined"&&typeof console.log!=="undefined")V?console.log(H,V):console.log(H);H==="No suitable players found and fallback enabled"&&f({message:H,code:4})};v.networkState=z.NETWORK_LOADING;z.dispatchEvent("loadstart");z.dispatchEvent("progress")}else h(function(){G(P)})}else{v.error=
83
+ {name:"MediaError",message:"Media Source Not Supported",code:MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED};z.dispatchEvent("error")}}function A(P){v.currentTime=P;if(B){O();K.seek(P)}else q(function(){O();K.seek(P)})}function O(){v.seeking=true;if(v.paused)s=true;z.dispatchEvent("seeking")}function a(){v.paused=false;if(M){M=false;if(v.loop&&!Q||!v.loop){Q=true;z.dispatchEvent("play")}z.dispatchEvent("playing")}}function c(){z.dispatchEvent("progress")}function n(){v.paused=true;if(!M){M=true;z.dispatchEvent("pause")}}
84
+ function j(){if(v.loop)A(0);else{v.ended=true;n();z.dispatchEvent("timeupdate");z.dispatchEvent("ended")}}function w(P){v.volume=P;if(B){K.setVolume(v.volume*100);z.dispatchEvent("volumechange")}else q(function(){w(v.volume)})}function x(P){v.muted=P;if(B){K.setMute(P);z.dispatchEvent("volumechange")}else q(function(){x(v.muted)})}if(!e.postMessage)throw"ERROR: HTMLJWPlayerVideoElement requires window.postMessage";var z=new p._MediaElementProto,F=typeof t==="string"?l.querySelector(t):t,v={src:g,
85
+ networkState:z.NETWORK_EMPTY,readyState:z.HAVE_NOTHING,seeking:false,autoplay:g,preload:g,controls:false,loop:false,poster:g,volume:1,muted:false,currentTime:0,duration:NaN,ended:false,paused:true,error:null},L=false,y=false,s=false,B=false,Q=false,K,M=true,D=[],T=true,I=false;z._eventNamespace=p.guid("HTMLJWPlayerVideoElement::");z.parentNode=F;z._util.type="JWPlayer";z.play=function(){z.dispatchEvent("play");v.paused=false;if(B){if(v.ended){A(0);v.ended=false}K.play(true)}else q(function(){z.play()})};
86
+ z.pause=function(){v.paused=true;B?K.pause(true):q(function(){z.pause()})};Object.defineProperties(z,{src:{get:function(){return v.src},set:function(P){P&&P!==v.src&&G(P)}},autoplay:{get:function(){return v.autoplay},set:function(P){v.autoplay=z._util.isAttributeSet(P)}},loop:{get:function(){return v.loop},set:function(P){v.loop=z._util.isAttributeSet(P)}},width:{get:function(){return z.parentNode.offsetWidth}},height:{get:function(){return z.parentNode.offsetHeight}},currentTime:{get:function(){return v.currentTime},
87
+ set:function(P){A(P)}},duration:{get:function(){return K.getDuration()}},ended:{get:function(){return v.ended}},paused:{get:function(){return v.paused}},seeking:{get:function(){return v.seeking}},readyState:{get:function(){return v.readyState}},networkState:{get:function(){return v.networkState}},volume:{get:function(){return v.volume},set:function(P){if(P<0||P>1)throw"Volume value must be between 0.0 and 1.0";w(P)}},muted:{get:function(){return v.muted},set:function(P){x(z._util.isAttributeSet(P))}},
88
+ error:{get:function(){return v.error}},buffered:{get:function(){var P={start:function(S){if(S===0)return 0;throw"INDEX_SIZE_ERR: DOM Exception 1";},end:function(S){if(S===0){S=K.getDuration();if(!S)return 0;return S*(K.getBuffer()/100)}throw"INDEX_SIZE_ERR: DOM Exception 1";}};Object.defineProperties(P,{length:{get:function(){return 1}}});return P}}});z._canPlaySrc=p.HTMLJWPlayerVideoElement._canPlaySrc;z.canPlayType=p.HTMLJWPlayerVideoElement.canPlayType;return z}var g="",k=false,r=false,m=[];p.HTMLJWPlayerVideoElement=
89
+ function(t){return new i(t)};p.HTMLJWPlayerVideoElement._canPlaySrc=function(){return"probably"};p.HTMLJWPlayerVideoElement.canPlayType=function(){return"probably"}})(Popcorn,window,document);(function(p,e){function l(i){this.startTime=0;this.currentTime=i.currentTime||0;this.duration=i.duration||NaN;this.playInterval=null;this.paused=true;this.playbackRate=this.defaultPlaybackRate=1;this.ended=i.endedCallback||p.nop}function d(i){function g(a){A.push(a)}function k(){if(!C)return 0;return f.currentTime}function r(a){if(a!==k())if(C){G.seeking=true;o.dispatchEvent("seeking");f.seekTo(a);G.ended=false;G.seeking=false;o.dispatchEvent("timeupdate");o.dispatchEvent("seeked");o.dispatchEvent("canplay");
90
+ o.dispatchEvent("canplaythrough")}else g(function(){r(a)})}function m(){o.dispatchEvent("timeupdate")}function t(){G.paused=true;clearInterval(O);o.dispatchEvent("pause")}function q(){if(G.loop){r(0);o.play()}else{G.ended=true;t();o.dispatchEvent("timeupdate");o.dispatchEvent("ended")}}var o=new p._MediaElementProto,u=typeof i==="string"?e.querySelector(i):i,E=e.createElement("div"),C=false,f,G={src:b,networkState:o.NETWORK_EMPTY,readyState:o.HAVE_NOTHING,autoplay:b,preload:b,controls:b,loop:false,
91
+ poster:b,volume:1,muted:false,width:u.width|0?u.width:o._util.MIN_WIDTH,height:u.height|0?u.height:o._util.MIN_HEIGHT,seeking:false,ended:false,paused:1,error:null},A=[],O;o._eventNamespace=p.guid("HTMLNullVideoElement::");o.parentNode=u;o._util.type="NullVideo";o.play=function(){if(C){f.play();if(G.paused){if(G.paused===1){G.paused=false;o.dispatchEvent("play");o.dispatchEvent("playing")}else{if(G.ended){r(0);G.ended=false}if(G.paused){G.paused=false;G.loop||o.dispatchEvent("play");o.dispatchEvent("playing")}}O=
92
+ setInterval(m,o._util.TIMEUPDATE_MS)}}else g(function(){o.play()})};o.pause=function(){if(C){f.pause();G.paused||t()}else g(function(){o.pause()})};Object.defineProperties(o,{src:{get:function(){return G.src},set:function(a){if(a&&a!==G.src)if(o._canPlaySrc(a)){G.src=a;if(C)if(C&&f){f.pause();f=null;u.removeChild(E);E=e.createElement("div")}E.width=G.width;E.height=G.height;u.appendChild(E);a=h.exec(a);f=new l({currentTime:+a[1],duration:+a[2],endedCallback:q});o.dispatchEvent("loadstart");o.dispatchEvent("progress");
93
+ o.dispatchEvent("durationchange");C=true;G.networkState=o.NETWORK_IDLE;G.readyState=o.HAVE_METADATA;o.dispatchEvent("loadedmetadata");o.dispatchEvent("loadeddata");G.readyState=o.HAVE_FUTURE_DATA;o.dispatchEvent("canplay");G.readyState=o.HAVE_ENOUGH_DATA;for(o.dispatchEvent("canplaythrough");A.length;){a=A.shift();a()}G.autoplay&&o.play()}else{G.error={name:"MediaError",message:"Media Source Not Supported",code:MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED};o.dispatchEvent("error")}}},autoplay:{get:function(){return G.autoplay},
94
+ set:function(a){G.autoplay=o._util.isAttributeSet(a)}},loop:{get:function(){return G.loop},set:function(a){G.loop=o._util.isAttributeSet(a)}},width:{get:function(){return E.width},set:function(a){E.width=a;G.width=E.width}},height:{get:function(){return E.height},set:function(a){E.height=a;G.height=E.height}},currentTime:{get:function(){return k()},set:function(a){r(a)}},duration:{get:function(){return f?f.duration:NaN}},ended:{get:function(){return G.ended}},paused:{get:function(){return G.paused}},
95
+ seeking:{get:function(){return G.seeking}},readyState:{get:function(){return G.readyState}},networkState:{get:function(){return G.networkState}},volume:{get:function(){return G.volume},set:function(a){if(a<0||a>1)throw"Volume value must be between 0.0 and 1.0";G.volume=a;o.dispatchEvent("volumechange")}},muted:{get:function(){return G.muted},set:function(a){a=o._util.isAttributeSet(a);G.muted=a;o.dispatchEvent("volumechange")}},playbackRate:{get:function(){return f.playbackRate},set:function(a){f.playbackRate=
96
+ a;o.dispatchEvent("ratechange")}},error:{get:function(){return G.error}}});o._canPlaySrc=p.HTMLNullVideoElement._canPlaySrc;o.canPlayType=p.HTMLNullVideoElement.canPlayType;return o}var b="",h=/#t=(\d+\.?\d*)?,?(\d+\.?\d*)/;l.prototype={play:function(){var i=this;if(this.paused){this.paused=false;this.startTime=Date.now();this.playInterval=setInterval(function(){i.currentTime+=(Date.now()-i.startTime)/(1E3/i.playbackRate);i.startTime=Date.now();if(i.currentTime>=i.duration){i.pause(i.duration);i.ended()}i.currentTime<
97
+ 0&&i.pause(0)},16)}},pause:function(){if(!this.paused){this.paused=true;clearInterval(this.playInterval)}},seekTo:function(i){i=i<0?0:i;this.currentTime=i=i>this.duration?this.duration:i}};p.HTMLNullVideoElement=function(i){return new d(i)};p.HTMLNullVideoElement._canPlaySrc=function(i){return h.test(i)?"probably":b};p.HTMLNullVideoElement.canPlayType=function(i){return i==="video/x-nullvideo"?"probably":b}})(Popcorn,document);(function(p,e,l){function d(k){var r=this,m=k.src.split("?")[0];if(m.substr(0,2)==="//")m=e.location.protocol+m;"play pause paused seekTo unload getCurrentTime getDuration getVideoEmbedCode getVideoHeight getVideoWidth getVideoUrl getColor setColor setLoop getVolume setVolume addEventListener".split(" ").forEach(function(t){r[t]=function(q){q=JSON.stringify({method:t,value:q});k.contentWindow&&k.contentWindow.postMessage(q,m)}})}function b(k){function r(y){z.unshift(y)}function m(y){var s=c.duration;
98
+ if(s!==y){c.duration=y;A.dispatchEvent("durationchange");if(isNaN(s)){c.networkState=A.NETWORK_IDLE;c.readyState=A.HAVE_METADATA;A.dispatchEvent("loadedmetadata");A.dispatchEvent("loadeddata");c.readyState=A.HAVE_FUTURE_DATA;A.dispatchEvent("canplay");c.readyState=A.HAVE_ENOUGH_DATA;A.dispatchEvent("canplaythrough");c.autoplay&&A.play();for(y=z.length;y--;){z[y]();delete z[y]}}}}function t(y){if(n){c.seeking=true;A.dispatchEvent("seeking");w.seekTo(y)}else r(function(){t(y)})}function q(){A.dispatchEvent("timeupdate")}
99
+ function o(y){(c.currentTime=y)!==L&&A.dispatchEvent("timeupdate");L=c.currentTime}function u(y){if(y.origin===g){var s;try{s=JSON.parse(y.data)}catch(B){console.warn(B)}if(s.player_id==j)switch(s.event){case "ready":w=new d(a);w.addEventListener("loadProgress");w.addEventListener("pause");w.setVolume(0);w.play();break;case "loadProgress":if(parseFloat(s.data.duration)>0&&!n){n=true;w.pause()}break;case "pause":w.setVolume(1);e.removeEventListener("message",u,false);e.addEventListener("message",E,
100
+ false);w.addEventListener("loadProgress");w.addEventListener("playProgress");w.addEventListener("play");w.addEventListener("pause");w.addEventListener("finish");w.addEventListener("seek");w.getDuration();c.networkState=A.NETWORK_LOADING;A.dispatchEvent("loadstart");A.dispatchEvent("progress")}}}function E(y){if(y.origin===g){var s;try{s=JSON.parse(y.data)}catch(B){console.warn(B)}if(s.player_id==j){switch(s.method){case "getCurrentTime":o(parseFloat(s.value));break;case "getDuration":m(parseFloat(s.value));
101
+ break;case "getVolume":y=parseFloat(s.value);if(c.volume!==y){c.volume=y;A.dispatchEvent("volumechange")}}switch(s.event){case "loadProgress":A.dispatchEvent("progress");m(parseFloat(s.data.duration));break;case "playProgress":o(parseFloat(s.data.seconds));break;case "play":c.ended&&t(0);if(!v){v=setInterval(C,h);c.loop&&A.dispatchEvent("play")}F=setInterval(q,A._util.TIMEUPDATE_MS);c.paused=false;if(x){x=false;c.loop||A.dispatchEvent("play");A.dispatchEvent("playing")}break;case "pause":c.paused=
102
+ true;if(!x){x=true;clearInterval(F);A.dispatchEvent("pause")}break;case "finish":if(c.loop){t(0);A.play()}else{c.ended=true;A.dispatchEvent("ended")}break;case "seek":o(parseFloat(s.data.seconds));c.seeking=false;A.dispatchEvent("timeupdate");A.dispatchEvent("seeked");A.dispatchEvent("canplay");A.dispatchEvent("canplaythrough")}}}}function C(){w.getCurrentTime()}function f(y){c.volume=y;if(n){w.setVolume(y);A.dispatchEvent("volumechange")}else r(function(){f(y)})}function G(y){if(n)if(y){c.muted=
103
+ c.volume;f(0)}else{c.muted=0;f(c.muted)}else{c.muted=y?1:0;r(function(){G(y)})}}if(!e.postMessage)throw"ERROR: HTMLVimeoVideoElement requires window.postMessage";var A=new p._MediaElementProto,O=typeof k==="string"?p.dom.find(k):k,a=l.createElement("iframe"),c={src:i,networkState:A.NETWORK_EMPTY,readyState:A.HAVE_NOTHING,seeking:false,autoplay:i,preload:i,controls:false,loop:false,poster:i,volume:1,muted:0,currentTime:0,duration:NaN,ended:false,paused:true,error:null},n=false,j=p.guid(),w,x=true,
104
+ z=[],F,v,L=0;A._eventNamespace=p.guid("HTMLVimeoVideoElement::");A.parentNode=O;A._util.type="Vimeo";A.play=function(){c.paused=false;n?w.play():r(function(){A.play()})};A.pause=function(){c.paused=true;n?w.pause():r(function(){A.pause()})};Object.defineProperties(A,{src:{get:function(){return c.src},set:function(y){if(y&&y!==c.src)if(A._canPlaySrc(y)){c.src=y;if(n)if(n&&w){clearInterval(v);w.pause();e.removeEventListener("message",E,false);O.removeChild(a);a=l.createElement("iframe")}n=false;y=A._util.parseUri(y);
105
+ var s=y.queryKey,B,Q=["api=1","player_id="+j,"title=0","byline=0","portrait=0"];c.loop=s.loop==="1"||c.loop;delete s.loop;c.autoplay=s.autoplay==="1"||c.autoplay;delete s.autoplay;y=g+"/video/"+/\d+$/.exec(y.path)+"?";for(B in s)s.hasOwnProperty(B)&&Q.push(encodeURIComponent(B)+"="+encodeURIComponent(s[B]));y+=Q.join("&");a.id=j;a.style.width="100%";a.style.height="100%";a.frameBorder=0;a.webkitAllowFullScreen=true;a.mozAllowFullScreen=true;a.allowFullScreen=true;O.appendChild(a);a.src=y;e.addEventListener("message",
106
+ u,false)}else{c.error={name:"MediaError",message:"Media Source Not Supported",code:MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED};A.dispatchEvent("error")}}},autoplay:{get:function(){return c.autoplay},set:function(y){c.autoplay=A._util.isAttributeSet(y)}},loop:{get:function(){return c.loop},set:function(y){c.loop=A._util.isAttributeSet(y)}},width:{get:function(){return A.parentNode.offsetWidth}},height:{get:function(){return A.parentNode.offsetHeight}},currentTime:{get:function(){return c.currentTime},
107
+ set:function(y){t(y)}},duration:{get:function(){return c.duration}},ended:{get:function(){return c.ended}},paused:{get:function(){return c.paused}},seeking:{get:function(){return c.seeking}},readyState:{get:function(){return c.readyState}},networkState:{get:function(){return c.networkState}},volume:{get:function(){return c.muted>0?c.muted:c.volume},set:function(y){if(y<0||y>1)throw"Volume value must be between 0.0 and 1.0";f(y)}},muted:{get:function(){return c.muted>0},set:function(y){G(A._util.isAttributeSet(y))}},
108
+ error:{get:function(){return c.error}}});A._canPlaySrc=p.HTMLVimeoVideoElement._canPlaySrc;A.canPlayType=p.HTMLVimeoVideoElement.canPlayType;return A}var h=16,i="",g="https://player.vimeo.com";p.HTMLVimeoVideoElement=function(k){return new b(k)};p.HTMLVimeoVideoElement._canPlaySrc=function(k){return/player.vimeo.com\/video\/\d+/.test(k)||/vimeo.com\/\d+/.test(k)?"probably":i};p.HTMLVimeoVideoElement.canPlayType=function(k){return k==="video/x-vimeo"?"probably":i}})(Popcorn,window,document);(function(p,e){function l(){return"maybe"}function d(b,h){var i=typeof b==="string"?e.querySelector(b):b,g=e.createElement(h);i.appendChild(g);g._canPlaySrc=l;return g}p.HTMLVideoElement=function(b){return d(b,"video")};p.HTMLVideoElement._canPlaySrc=l;p.HTMLAudioElement=function(b){return d(b,"audio")};p.HTMLAudioElement._canPlaySrc=l})(Popcorn,window.document);(function(p,e,l){function d(){var u;if(YT.loaded)for(t=true;o.length;){u=o.shift();u()}else setTimeout(d,250)}function b(){var u;if(!q){if(e.YT)d();else{u=l.createElement("script");u.addEventListener("load",d,false);u.src="https://www.youtube.com/iframe_api";l.head.appendChild(u)}q=true}return t}function h(u){o.push(u)}function i(u){function E(J){W.push(J)}function C(){R.pauseVideo();j("play",C);n("play",K)}function f(){n("pause",M);j("pause",f)}function G(){var J=function(){if(R.isMuted()){n("play",
109
+ c);R.playVideo()}else setTimeout(J,0)};V=true;R.mute();J()}function A(J){var N={name:"MediaError"};switch(J.data){case 2:N.message="Invalid video parameter.";N.code=MediaError.MEDIA_ERR_ABORTED;break;case 5:N.message="The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.";N.code=MediaError.MEDIA_ERR_DECODE;case 100:N.message="Video not found.";N.code=MediaError.MEDIA_ERR_NETWORK;break;case 101:case 150:N.message="Video not usable.";N.code=
110
+ MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:N.message="Unknown error.";N.code=5}H.error=N;I.dispatchEvent("error")}function O(){n("play",K);n("pause",M);if(H.autoplay||!H.paused){j("play",O);H.paused=false;E(function(){H.paused||K()})}H.muted||R.unMute();H.readyState=I.HAVE_METADATA;I.dispatchEvent("loadedmetadata");aa=setInterval(v,g);I.dispatchEvent("loadeddata");H.readyState=I.HAVE_FUTURE_DATA;I.dispatchEvent("canplay");U=true;for(ba=setInterval(L,50);W.length;){W[0]();W.shift()}H.readyState=
111
+ I.HAVE_ENOUGH_DATA;I.dispatchEvent("canplaythrough")}function a(){j("pause",a);if(R.getCurrentTime()>0)setTimeout(a,0);else if(H.autoplay||!H.paused){n("play",O);R.playVideo()}else O()}function c(){j("play",c);if(R.getCurrentTime()===0)setTimeout(c,0);else{n("pause",a);R.seekTo(0);R.pauseVideo()}}function n(J,N){I.addEventListener("youtube-"+J,N,false)}function j(J,N){I.removeEventListener("youtube-"+J,N,false)}function w(J){I.dispatchEvent("youtube-"+J)}function x(){H.networkState=I.NETWORK_LOADING;
112
+ I.dispatchEvent("waiting")}function z(J){switch(J.data){case YT.PlayerState.ENDED:w("ended");break;case YT.PlayerState.PLAYING:w("play");break;case YT.PlayerState.PAUSED:R.getDuration()!==R.getCurrentTime()&&w("pause");break;case YT.PlayerState.BUFFERING:w("buffering")}J.data!==YT.PlayerState.BUFFERING&&ca===YT.PlayerState.BUFFERING&&I.dispatchEvent("progress");ca=J.data}function F(J){if(I._canPlaySrc(J)){H.src=J;if(b()){if(V)if(U){if(V&&R){j("buffering",x);j("ended",D);j("play",K);j("pause",M);M();
113
+ Z=U=false;H.currentTime=0;W=[];clearInterval(aa);clearInterval(ba);R.stopVideo();R.clearVideo();R.destroy();S=l.createElement("div")}}else{E(function(){F(J)});return}P.appendChild(S);var N=I._util.parseUri(J).queryKey;delete N.v;H.autoplay=N.autoplay==="1"||H.autoplay;delete N.autoplay;H.loop=N.loop==="1"||H.loop;delete N.loop;N.rel=N.rel||0;N.modestbranding=N.modestbranding||1;N.iv_load_policy=N.iv_load_policy||3;N.disablekb=N.disablekb||1;N.showinfo=N.showinfo||0;var ea=e.location.protocol==="file:"?
114
+ "*":e.location.protocol+"//"+e.location.host;N.origin=N.origin||ea;N.controls=N.controls||H.controls?2:0;H.controls=N.controls;N.wmode=N.wmode||"opaque";J=r.exec(J)[1];p.getJSONP("https://gdata.youtube.com/feeds/api/videos/"+J+"?v=2&alt=jsonc&callback=?",function(X){if(X.error)console.warn("failed to retreive duration data, reason: "+X.error.message);else if(X.data){H.duration=X.data.duration;I.dispatchEvent("durationchange");R=new YT.Player(S,{width:"100%",height:"100%",wmode:N.wmode,videoId:J,playerVars:N,
115
+ events:{onReady:G,onError:A,onStateChange:z}});H.networkState=I.NETWORK_LOADING;I.dispatchEvent("loadstart");I.dispatchEvent("progress")}else console.warn("failed to retreive duration data, reason: no response data")})}else h(function(){F(J)})}else{H.error={name:"MediaError",message:"Media Source Not Supported",code:MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED};I.dispatchEvent("error")}}function v(){var J=R.getCurrentTime();if(H.seeking)m(J-H.currentTime)<1&&Q();else{if(m(H.currentTime-J)>g){B();Q()}H.currentTime=
116
+ J}}function L(){var J=R.getVideoLoadedFraction();if(J&&$!==J){$=J;I.dispatchEvent("progress")}}function y(J){if(J!==H.currentTime){H.currentTime=J;if(U){B();R.seekTo(J)}else E(function(){B();R.seekTo(J)})}}function s(){I.dispatchEvent("timeupdate")}function B(){n("pause",f);j("pause",M);H.seeking=true;I.dispatchEvent("seeking")}function Q(){H.ended=false;H.seeking=false;I.dispatchEvent("timeupdate");I.dispatchEvent("seeked");I.dispatchEvent("canplay");I.dispatchEvent("canplaythrough")}function K(){if(H.ended){y(0);
117
+ H.ended=false}da=setInterval(s,I._util.TIMEUPDATE_MS);H.paused=false;if(Y){Y=false;if(H.loop&&!Z||!H.loop){Z=true;I.dispatchEvent("play")}I.dispatchEvent("playing")}}function M(){H.paused=true;if(!Y){Y=true;clearInterval(da);I.dispatchEvent("pause")}}function D(){if(H.loop){y(0);I.play()}else{H.ended=true;M();n("play",C);j("play",K);I.dispatchEvent("timeupdate");I.dispatchEvent("ended")}}function T(J){H.muted=J;if(U){R[J?"mute":"unMute"]();I.dispatchEvent("volumechange")}else E(function(){T(H.muted)})}
118
+ if(!e.postMessage)throw"ERROR: HTMLYouTubeVideoElement requires window.postMessage";var I=new p._MediaElementProto,P=typeof u==="string"?l.querySelector(u):u,S=l.createElement("div"),H={src:k,networkState:I.NETWORK_EMPTY,readyState:I.HAVE_NOTHING,seeking:false,autoplay:k,preload:k,controls:false,loop:false,poster:k,volume:1,muted:false,currentTime:0,duration:NaN,ended:false,paused:true,error:null},V=false,U=false,Z=false,R,Y=true,W=[],ca=-1,ba,$=0,aa,da;I._eventNamespace=p.guid("HTMLYouTubeVideoElement::");
119
+ I.parentNode=P;I._util.type="YouTube";n("buffering",x);n("ended",D);I.play=function(){H.paused=false;U?R.playVideo():E(function(){I.play()})};I.pause=function(){H.paused=true;if(U){f();R.pauseVideo()}else E(function(){I.pause()})};Object.defineProperties(I,{src:{get:function(){return H.src},set:function(J){J&&J!==H.src&&F(J)}},autoplay:{get:function(){return H.autoplay},set:function(J){H.autoplay=I._util.isAttributeSet(J)}},loop:{get:function(){return H.loop},set:function(J){H.loop=I._util.isAttributeSet(J)}},
120
+ width:{get:function(){return I.parentNode.offsetWidth}},height:{get:function(){return I.parentNode.offsetHeight}},currentTime:{get:function(){return H.currentTime},set:function(J){y(J)}},duration:{get:function(){return H.duration}},ended:{get:function(){return H.ended}},paused:{get:function(){return H.paused}},seeking:{get:function(){return H.seeking}},readyState:{get:function(){return H.readyState}},networkState:{get:function(){return H.networkState}},volume:{get:function(){return H.volume},set:function(J){if(J<
121
+ 0||J>1)throw"Volume value must be between 0.0 and 1.0";H.volume=J;if(U){R.setVolume(H.volume*100);I.dispatchEvent("volumechange")}else E(function(){I.volume=J})}},muted:{get:function(){return H.muted},set:function(J){T(I._util.isAttributeSet(J))}},error:{get:function(){return H.error}},buffered:{get:function(){var J={start:function(N){if(N===0)return 0;throw"INDEX_SIZE_ERR: DOM Exception 1";},end:function(N){if(N===0){if(!H.duration)return 0;return H.duration*$}throw"INDEX_SIZE_ERR: DOM Exception 1";
122
+ }};Object.defineProperties(J,{length:{get:function(){return 1}}});return J},configurable:true}});I._canPlaySrc=p.HTMLYouTubeVideoElement._canPlaySrc;I.canPlayType=p.HTMLYouTubeVideoElement.canPlayType;return I}var g=10,k="",r=/^.*(?:\/|v=)(.{11})/,m=Math.abs,t=false,q=false,o=[];p.HTMLYouTubeVideoElement=function(u){return new i(u)};p.HTMLYouTubeVideoElement._canPlaySrc=function(u){return/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(youtu).*(?:\/|v=)(.{11})/.test(u)?"probably":k};p.HTMLYouTubeVideoElement.canPlayType=
123
+ function(u){return u==="video/x-youtube"?"probably":k}})(Popcorn,window,document);(function(p,e,l){function d(){if(!r){p.getScript("https://w.soundcloud.com/player/api.js",function(){p.getScript("https://connect.soundcloud.com/sdk.js",function(){k=true;SC.initialize({client_id:"PRaNFlda6Bhf5utPjUsptg"});for(var t=m.length;t--;){m[t]();delete m[t]}})});r=true}return k}function b(t){m.unshift(t)}function h(t){function q(D){B.unshift(D)}function o(){s.bind(SC.Widget.Events.LOAD_PROGRESS,function(D){O({type:"loadProgress",data:D.currentPosition/1E3})});s.bind(SC.Widget.Events.PLAY_PROGRESS,
124
+ function(D){O({type:"playProgress",data:D.currentPosition/1E3})});s.bind(SC.Widget.Events.PLAY,function(){O({type:"play"})});s.bind(SC.Widget.Events.PAUSE,function(){O({type:"pause"})});s.bind(SC.Widget.Events.SEEK,function(){s.getPosition(function(D){D=D/1E3;if(v.seeking)if(Math.floor(D)!==Math.floor(v.currentTime))s.seekTo(v.currentTime*1E3);else{v.ended=false;v.seeking=false;x.dispatchEvent("timeupdate");x.dispatchEvent("seeked");x.dispatchEvent("canplay");x.dispatchEvent("canplaythrough")}else O({type:"seek",
125
+ data:D})})});s.bind(SC.Widget.Events.FINISH,function(){O({type:"finish"})});L=true;s.getDuration(E)}function u(){s.bind(SC.Widget.Events.PLAY_PROGRESS,function(D){s.setVolume(0);if(D.currentPosition>0){s.unbind(SC.Widget.Events.PLAY_PROGRESS);s.bind(SC.Widget.Events.PAUSE,function(){s.unbind(SC.Widget.Events.PAUSE);s.setVolume(100);s.bind(SC.Widget.Events.SEEK,function(){s.unbind(SC.Widget.Events.SEEK);o()});s.seekTo(0)});s.pause()}});s.play()}function E(D){D/=1E3;var T=v.duration;if(T!==D){v.duration=
126
+ D;x.dispatchEvent("durationchange");if(isNaN(T)){v.networkState=x.NETWORK_IDLE;v.readyState=x.HAVE_METADATA;x.dispatchEvent("loadedmetadata");x.dispatchEvent("loadeddata");v.readyState=x.HAVE_FUTURE_DATA;x.dispatchEvent("canplay");v.readyState=x.HAVE_ENOUGH_DATA;x.dispatchEvent("canplaythrough");for(D=B.length;D--;){B[D]();delete B[D]}v.paused&&v.autoplay&&x.play()}}}function C(D){function T(){v.seeking=true;x.dispatchEvent("seeking");s.seekTo(D)}v.currentTime=D;D*=1E3;L?T():addMediaReadyCallback(T)}
127
+ function f(){v.paused=true;if(!y){y=true;clearInterval(Q);x.dispatchEvent("pause")}}function G(){x.dispatchEvent("timeupdate")}function A(D){v.currentTime=D;D!==M&&x.dispatchEvent("timeupdate");M=D}function O(D){switch(D.type){case "loadProgress":x.dispatchEvent("progress");break;case "playProgress":A(D.data);break;case "play":if(!K){K=setInterval(a,i);v.loop&&x.dispatchEvent("play")}Q=setInterval(G,x._util.TIMEUPDATE_MS);v.paused=false;if(y){y=false;v.loop||x.dispatchEvent("play");x.dispatchEvent("playing")}break;
128
+ case "pause":f();break;case "finish":if(v.loop){C(0);x.play()}else{v.ended=true;x.pause();f();x.dispatchEvent("timeupdate");x.dispatchEvent("ended")}break;case "seek":A(D.data)}}function a(){v.ended||s.getPosition(function(D){A(D/1E3)})}function c(D){if(x._canPlaySrc(D)){v.src=D;if(L)if(L&&s){clearInterval(K);s.pause();s.unbind(SC.Widget.Events.READY);s.unbind(SC.Widget.Events.LOAD_PROGRESS);s.unbind(SC.Widget.Events.PLAY_PROGRESS);s.unbind(SC.Widget.Events.PLAY);s.unbind(SC.Widget.Events.PAUSE);
129
+ s.unbind(SC.Widget.Events.SEEK);s.unbind(SC.Widget.Events.FINISH);z.removeChild(F);F=l.createElement("iframe")}if(d()){L=false;SC.get("/resolve",{url:D},function(T){var I;if(T.errors){I={name:"MediaError"};if(T.errors[0])if(T.errors[0].error_message==="404 - Not Found"){I.message="Video not found.";I.code=MediaError.MEDIA_ERR_NETWORK}v.error=I;x.dispatchEvent("error")}F.id=p.guid("soundcloud-");F.width=v.width;F.height=v.height;F.frameBorder=0;F.webkitAllowFullScreen=true;F.mozAllowFullScreen=true;
130
+ F.allowFullScreen=true;w(v.controls);z.appendChild(F);F.onload=function(){F.onload=null;s=SC.Widget(F);s.bind(SC.Widget.Events.READY,u);v.networkState=x.NETWORK_LOADING;x.dispatchEvent("loadstart");x.dispatchEvent("progress")};F.src="https://w.soundcloud.com/player/?url="+T.uri+"&show_artwork=false&buying=false&liking=false&sharing=false&download=false&show_comments=false&show_user=false&single_active=false"})}else b(function(){c(D)})}else{v.error={name:"MediaError",message:"Media Source Not Supported",
131
+ code:MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED};x.dispatchEvent("error")}}function n(D){v.volume=D;if(L){s.setVolume(D);x.dispatchEvent("volumechange")}else q(function(){n(D)})}function j(D){if(L)if(D){v.muted=v.volume;n(0)}else{v.muted=0;n(v.muted)}else{v.muted=D?1:0;q(function(){j(D)})}}function w(D){if(L){F.style.position="absolute";F.style.visibility=D?"visible":"hidden"}else{F.style.opacity=D?"1":"0";F.style.pointerEvents=D?"auto":"none"}v.controls=D}if(!e.postMessage)throw"ERROR: HTMLSoundCloudAudioElement requires window.postMessage";
132
+ var x=new p._MediaElementProto,z=typeof t==="string"?p.dom.find(t):t,F=l.createElement("iframe"),v={src:g,networkState:x.NETWORK_EMPTY,readyState:x.HAVE_NOTHING,seeking:false,autoplay:g,preload:g,controls:false,loop:false,poster:g,volume:100,muted:0,currentTime:0,duration:NaN,ended:false,paused:true,width:z.width|0?z.width:x._util.MIN_WIDTH,height:z.height|0?z.height:x._util.MIN_HEIGHT,error:null},L=false,y=true,s,B=[],Q,K,M=0;x._eventNamespace=p.guid("HTMLSoundCloudAudioElement::");x.parentNode=
133
+ z;x._util.type="SoundCloud";x.play=function(){v.paused=false;if(L){v.ended&&C(0);s.play()}else q(function(){x.play()})};x.pause=function(){v.paused=true;L?s.pause():q(function(){x.pause()})};Object.defineProperties(x,{src:{get:function(){return v.src},set:function(D){D&&D!==v.src&&c(D)}},autoplay:{get:function(){return v.autoplay},set:function(D){v.autoplay=x._util.isAttributeSet(D)}},loop:{get:function(){return v.loop},set:function(D){v.loop=x._util.isAttributeSet(D)}},width:{get:function(){return F.width},
134
+ set:function(D){F.width=D;v.width=F.width}},height:{get:function(){return F.height},set:function(D){F.height=D;v.height=F.height}},currentTime:{get:function(){return v.currentTime},set:function(D){C(D)}},duration:{get:function(){return v.duration}},ended:{get:function(){return v.ended}},paused:{get:function(){return v.paused}},seeking:{get:function(){return v.seeking}},readyState:{get:function(){return v.readyState}},networkState:{get:function(){return v.networkState}},volume:{get:function(){return(v.muted>
135
+ 0?v.muted:v.volume)/100},set:function(D){if(D<0||D>1)throw"Volume value must be between 0.0 and 1.0";D*=100;n(D)}},muted:{get:function(){return v.muted>0},set:function(D){j(x._util.isAttributeSet(D))}},error:{get:function(){return v.error}},controls:{get:function(){return v.controls},set:function(D){w(!!D)}}});x._canPlaySrc=p.HTMLSoundCloudAudioElement._canPlaySrc;x.canPlayType=p.HTMLSoundCloudAudioElement.canPlayType;return x}var i=16,g="",k=false,r=false,m=[];p.HTMLSoundCloudAudioElement=function(t){return new h(t)};
136
+ p.HTMLSoundCloudAudioElement._canPlaySrc=function(t){return/(?:https?:\/\/www\.|https?:\/\/|www\.|\.|^)(soundcloud)/.test(t)?"probably":g};p.HTMLSoundCloudAudioElement.canPlayType=function(t){return t==="audio/x-soundcloud"?"probably":g}})(Popcorn,window,document);(function(p){var e=function(l,d){var b=0,h=0,i;p.forEach(d.classes,function(g,k){i=[];if(g==="parent")i[0]=document.querySelectorAll("#"+d.target)[0].parentNode;else i=document.querySelectorAll("#"+d.target+" "+g);b=0;for(h=i.length;b<h;b++)i[b].classList.toggle(k)})};p.compose("applyclass",{manifest:{about:{name:"Popcorn applyclass Effect",version:"0.1",author:"@scottdowne",website:"scottdowne.wordpress.com"},options:{}},_setup:function(l){l.classes={};l.applyclass=l.applyclass||"";for(var d=l.applyclass.replace(/\s/g,
137
+ "").split(","),b=[],h=0,i=d.length;h<i;h++){b=d[h].split(":");if(b[0])l.classes[b[0]]=b[1]||""}},start:e,end:e})})(Popcorn);(function(p){function e(d,b){if(d.map)d.map.div.style.display=b;else setTimeout(function(){e(d,b)},10)}var l=1;p.plugin("openmap",function(d){var b,h,i,g,k,r,m,t,q=document.getElementById(d.target);b=document.createElement("div");b.id="openmapdiv"+l;b.style.width="100%";b.style.height="100%";l++;q&&q.appendChild(b);t=function(){if(window.OpenLayers&&window.OpenLayers.Layer.Stamen){if(d.location){location=new OpenLayers.LonLat(0,0);p.getJSONP("//tinygeocoder.com/create-api.php?q="+d.location+"&callback=jsonp",
138
+ function(u){h=new OpenLayers.LonLat(u[1],u[0])})}else h=new OpenLayers.LonLat(d.lng,d.lat);d.type=d.type||"ROADMAP";switch(d.type){case "SATELLITE":d.map=new OpenLayers.Map({div:b,maxResolution:0.28125,tileSize:new OpenLayers.Size(512,512)});var o=new OpenLayers.Layer.WorldWind("LANDSAT","//worldwind25.arc.nasa.gov/tile/tile.aspx",2.25,4,{T:"105"});d.map.addLayer(o);g=new OpenLayers.Projection("EPSG:4326");i=new OpenLayers.Projection("EPSG:4326");break;case "TERRAIN":g=new OpenLayers.Projection("EPSG:4326");
139
+ i=new OpenLayers.Projection("EPSG:4326");d.map=new OpenLayers.Map({div:b,projection:i});o=new OpenLayers.Layer.WMS("USGS Terraserver","//terraserver-usa.org/ogcmap.ashx?",{layers:"DRG"});d.map.addLayer(o);break;case "STAMEN-TONER":case "STAMEN-WATERCOLOR":case "STAMEN-TERRAIN":o=d.type.replace("STAMEN-","").toLowerCase();o=new OpenLayers.Layer.Stamen(o);g=new OpenLayers.Projection("EPSG:4326");i=new OpenLayers.Projection("EPSG:900913");h=h.transform(g,i);d.map=new OpenLayers.Map({div:b,projection:i,
140
+ displayProjection:g,controls:[new OpenLayers.Control.Navigation,new OpenLayers.Control.PanPanel,new OpenLayers.Control.ZoomPanel]});d.map.addLayer(o);break;default:i=new OpenLayers.Projection("EPSG:900913");g=new OpenLayers.Projection("EPSG:4326");h=h.transform(g,i);d.map=new OpenLayers.Map({div:b,projection:i,displayProjection:g});o=new OpenLayers.Layer.OSM;d.map.addLayer(o)}if(d.map){d.map.setCenter(h,d.zoom||10);d.map.div.style.display="none"}}else setTimeout(function(){t()},50)};t();return{_setup:function(o){window.OpenLayers||
141
+ p.getScript("//openlayers.org/api/OpenLayers.js",function(){p.getScript("//maps.stamen.com/js/tile.stamen.js")});var u=function(){if(o.map){o.zoom=o.zoom||2;if(o.zoom&&typeof o.zoom!=="number")o.zoom=+o.zoom;o.map.setCenter(h,o.zoom);if(o.markers){var E=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style["default"]),C=function(j){clickedFeature=j.feature;if(clickedFeature.attributes.text){m=new OpenLayers.Popup.FramedCloud("featurePopup",clickedFeature.geometry.getBounds().getCenterLonLat(),
142
+ new OpenLayers.Size(120,250),clickedFeature.attributes.text,null,true,function(){r.unselect(this.feature)});clickedFeature.popup=m;m.feature=clickedFeature;o.map.addPopup(m)}},f=function(j){feature=j.feature;if(feature.popup){m.feature=null;o.map.removePopup(feature.popup);feature.popup.destroy();feature.popup=null}},G=function(j){p.getJSONP("//tinygeocoder.com/create-api.php?q="+j.location+"&callback=jsonp",function(w){w=(new OpenLayers.Geometry.Point(w[1],w[0])).transform(g,i);var x=OpenLayers.Util.extend({},
143
+ E);if(!j.size||isNaN(j.size))j.size=14;x.pointRadius=j.size;x.graphicOpacity=1;x.externalGraphic=j.icon;w=new OpenLayers.Feature.Vector(w,null,x);if(j.text)w.attributes={text:j.text};k.addFeatures([w])})};k=new OpenLayers.Layer.Vector("Point Layer",{style:E});o.map.addLayer(k);for(var A=0,O=o.markers.length;A<O;A++){var a=o.markers[A];if(a.text)if(!r){r=new OpenLayers.Control.SelectFeature(k);o.map.addControl(r);r.activate();k.events.on({featureselected:C,featureunselected:f})}if(a.location)G(a);
144
+ else{var c=(new OpenLayers.Geometry.Point(a.lng,a.lat)).transform(g,i),n=OpenLayers.Util.extend({},E);if(!a.size||isNaN(a.size))a.size=14;n.pointRadius=a.size;n.graphicOpacity=1;n.externalGraphic=a.icon;c=new OpenLayers.Feature.Vector(c,null,n);if(a.text)c.attributes={text:a.text};k.addFeatures([c])}}}}else setTimeout(function(){u()},13)};u()},start:function(o,u){e(u,"block")},end:function(o,u){e(u,"none")},_teardown:function(){q&&q.removeChild(b);b=map=h=i=g=k=r=m=null}}},{about:{name:"Popcorn OpenMap Plugin",
117
145
  version:"0.3",author:"@mapmeld",website:"mapadelsur.blogspot.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"map-container",type:{elem:"select",options:["ROADMAP","SATELLITE","TERRAIN"],label:"Map Type",optional:true},zoom:{elem:"input",type:"number",label:"Zoom","default":2},lat:{elem:"input",type:"text",label:"Lat",optional:true},lng:{elem:"input",type:"text",label:"Lng",optional:true},location:{elem:"input",type:"text",label:"Location",
118
- "default":"Toronto, Ontario, Canada"},markers:{elem:"input",type:"text",label:"List Markers",optional:true}}})})(Popcorn);document.addEventListener("click",function(r){r=r.target;if(r.nodeName==="A"||r.parentNode&&r.parentNode.nodeName==="A")Popcorn.instances.forEach(function(f){f.options.pauseOnLinkClicked&&f.pause()})},false);(function(r){var f={},n=0,c=document.createElement("span"),b=["webkit","Moz","ms","O",""],e=["Transform","TransitionDuration","TransitionTimingFunction"],h={},i;document.getElementsByTagName("head")[0].appendChild(c);for(var j=0,p=e.length;j<p;j++)for(var m=0,o=b.length;m<o;m++){i=b[m]+e[j];if(i in c.style){h[e[j].toLowerCase()]=i;break}}document.getElementsByTagName("head")[0].appendChild(c);r.plugin("wordriver",{manifest:{about:{name:"Popcorn WordRiver Plugin"},options:{start:{elem:"input",type:"number",
119
- label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"wordriver-container",text:{elem:"input",type:"text",label:"Text","default":"Popcorn.js"},color:{elem:"input",type:"text",label:"Color","default":"Green",optional:true}}},_setup:function(q){q._duration=q.end-q.start;var s;if(!(s=f[q.target])){s=q.target;f[s]=document.createElement("div");var d=document.getElementById(s);d&&d.appendChild(f[s]);f[s].style.height="100%";f[s].style.position="relative";s=f[s]}q._container=s;q.word=document.createElement("span");
120
- q.word.style.position="absolute";q.word.style.whiteSpace="nowrap";q.word.style.opacity=0;q.word.style.MozTransitionProperty="opacity, -moz-transform";q.word.style.webkitTransitionProperty="opacity, -webkit-transform";q.word.style.OTransitionProperty="opacity, -o-transform";q.word.style.transitionProperty="opacity, transform";q.word.style[h.transitionduration]="1s, "+q._duration+"s";q.word.style[h.transitiontimingfunction]="linear";q.word.innerHTML=q.text;q.word.style.color=q.color||"black"},start:function(q,
121
- s){s._container.appendChild(s.word);s.word.style[h.transform]="";s.word.style.fontSize=~~(30+20*Math.random())+"px";n%=s._container.offsetWidth-s.word.offsetWidth;s.word.style.left=n+"px";n+=s.word.offsetWidth+10;s.word.style[h.transform]="translateY("+(s._container.offsetHeight-s.word.offsetHeight)+"px)";s.word.style.opacity=1;setTimeout(function(){s.word.style.opacity=0},(s.end-s.start-1||1)*1E3)},end:function(q,s){s.word.style.opacity=0},_teardown:function(q){var s=document.getElementById(q.target);
122
- q.word.parentNode&&q._container.removeChild(q.word);f[q.target]&&!f[q.target].childElementCount&&s&&s.removeChild(f[q.target])&&delete f[q.target]}})})(Popcorn);(function(r){var f=1;r.plugin("timeline",function(n){var c=document.getElementById(n.target),b=document.createElement("div"),e,h=true;if(c&&!c.firstChild){c.appendChild(e=document.createElement("div"));e.style.width="inherit";e.style.height="inherit";e.style.overflow="auto"}else e=c.firstChild;b.style.display="none";b.id="timelineDiv"+f;n.direction=n.direction||"up";if(n.direction.toLowerCase()==="down")h=false;if(c&&e)h?e.insertBefore(b,e.firstChild):e.appendChild(b);f++;b.innerHTML="<p><span id='big' style='font-size:24px; line-height: 130%;' >"+
123
- n.title+"</span><br /><span id='mid' style='font-size: 16px;'>"+n.text+"</span><br />"+n.innerHTML;return{start:function(i,j){b.style.display="block";if(j.direction==="down")e.scrollTop=e.scrollHeight},end:function(){b.style.display="none"},_teardown:function(){e&&b&&e.removeChild(b)&&!e.firstChild&&c.removeChild(e)}}},{about:{name:"Popcorn Timeline Plugin",version:"0.1",author:"David Seifried @dcseifried",website:"dseifried.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},
124
- end:{elem:"input",type:"number",label:"End"},target:"feed-container",title:{elem:"input",type:"text",label:"Title"},text:{elem:"input",type:"text",label:"Text"},innerHTML:{elem:"input",type:"text",label:"HTML Code",optional:true},direction:{elem:"select",options:["DOWN","UP"],label:"Direction",optional:true}}})})(Popcorn);(function(r,f){var n={};r.plugin("documentcloud",{manifest:{about:{name:"Popcorn Document Cloud Plugin",version:"0.1",author:"@humphd, @ChrisDeCairos",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"documentcloud-container",width:{elem:"input",type:"text",label:"Width",optional:true},height:{elem:"input",type:"text",label:"Height",optional:true},src:{elem:"input",type:"url",label:"PDF URL","default":"http://www.documentcloud.org/documents/70050-urbina-day-1-in-progress.html"},
125
- preload:{elem:"input",type:"checkbox",label:"Preload","default":true},page:{elem:"input",type:"number",label:"Page Number",optional:true},aid:{elem:"input",type:"number",label:"Annotation Id",optional:true}}},_setup:function(c){function b(){function m(v){c._key=v.api.getId();c._changeView=function(z){c.aid?z.pageSet.showAnnotation(z.api.getAnnotation(c.aid)):z.api.setCurrentPage(c.page)}}function o(){n[c._key]={num:1,id:c._containerId};h.loaded=true}h.loaded=false;var q=c.url.replace(/\.html$/,".js"),
126
- s=c.target,d=f.getElementById(s),A=f.createElement("div"),y=r.position(d),x=c.width||y.width;y=c.height||y.height;var a=c.sidebar||true,g=c.text||true,l=c.pdf||true,k=c.showAnnotations||true,t=c.zoom||700,u=c.search||true;if(!function(v){var z=false;r.forEach(h.viewers,function(C){if(C.api.getSchema().canonicalURL===v){m(C);C=n[c._key];c._containerId=C.id;C.num+=1;z=true;h.loaded=true}});return z}(c.url)){A.id=c._containerId=r.guid(s);s="#"+A.id;d.appendChild(A);i.trigger("documentready");h.load(q,
127
- {width:x,height:y,sidebar:a,text:g,pdf:l,showAnnotations:k,zoom:t,search:u,container:s,afterLoad:c.page||c.aid?function(v){m(v);c._changeView(v);A.style.visibility="hidden";v.elements.pages.hide();o()}:function(v){m(v);o();A.style.visibility="hidden";v.elements.pages.hide()}})}}function e(){window.DV.loaded?b():setTimeout(e,25)}var h=window.DV=window.DV||{},i=this;if(h.loading)e();else{h.loading=true;h.recordHit="//www.documentcloud.org/pixel.gif";var j=f.createElement("link"),p=f.getElementsByTagName("head")[0];
128
- j.rel="stylesheet";j.type="text/css";j.media="screen";j.href="//s3.documentcloud.org/viewer/viewer-datauri.css";p.appendChild(j);h.loaded=false;r.getScript("http://s3.documentcloud.org/viewer/viewer.js",function(){h.loading=false;b()})}},start:function(c,b){var e=f.getElementById(b._containerId),h=DV.viewers[b._key];(b.page||b.aid)&&h&&b._changeView(h);if(e&&h){e.style.visibility="visible";h.elements.pages.show()}},end:function(c,b){var e=f.getElementById(b._containerId);if(e&&DV.viewers[b._key]){e.style.visibility=
129
- "hidden";DV.viewers[b._key].elements.pages.hide()}},_teardown:function(c){var b=f.getElementById(c._containerId);if((c=c._key)&&DV.viewers[c]&&--n[c].num===0){for(DV.viewers[c].api.unload();b.hasChildNodes();)b.removeChild(b.lastChild);b.parentNode.removeChild(b)}}})})(Popcorn,window.document);(function(r){r.parser("parseJSON","JSON",function(f){var n={title:"",remote:"",data:[]};r.forEach(f.data,function(c){n.data.push(c)});return n})})(Popcorn);(function(r){r.parser("parseSBV",function(f){var n={title:"",remote:"",data:[]},c=[],b=0,e=0,h=function(q){q=q.split(":");var s=q.length-1,d;try{d=parseInt(q[s-1],10)*60+parseFloat(q[s],10);if(s===2)d+=parseInt(q[0],10)*3600}catch(A){throw"Bad cue";}return d},i=function(q,s){var d={};d[q]=s;return d};f=f.text.split(/(?:\r\n|\r|\n)/gm);for(e=f.length;b<e;){var j={},p=[],m=f[b++].split(",");try{j.start=h(m[0]);for(j.end=h(m[1]);b<e&&f[b];)p.push(f[b++]);j.text=p.join("<br />");c.push(i("subtitle",j))}catch(o){for(;b<
130
- e&&f[b];)b++}for(;b<e&&!f[b];)b++}n.data=c;return n})})(Popcorn);(function(r){function f(c,b){var e={};e[c]=b;return e}function n(c){c=c.split(":");try{var b=c[2].split(",");if(b.length===1)b=c[2].split(".");return parseFloat(c[0],10)*3600+parseFloat(c[1],10)*60+parseFloat(b[0],10)+parseFloat(b[1],10)/1E3}catch(e){return 0}}r.parser("parseSRT",function(c){var b={title:"",remote:"",data:[]},e=[],h=0,i=0,j,p,m,o;c=c.text.split(/(?:\r\n|\r|\n)/gm);for(h=c.length-1;h>=0&&!c[h];)h--;m=h+1;for(h=0;h<m;h++){o={};p=[];o.id=parseInt(c[h++],10);j=c[h++].split(/[\t ]*--\>[\t ]*/);
131
- o.start=n(j[0]);i=j[1].indexOf(" ");if(i!==-1)j[1]=j[1].substr(0,i);for(o.end=n(j[1]);h<m&&c[h];)p.push(c[h++]);o.text=p.join("\\N").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,"");o.text=o.text.replace(/</g,"&lt;").replace(/>/g,"&gt;");o.text=o.text.replace(/&lt;(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)(\/?)&gt;/gi,"<$1$3$7>");o.text=o.text.replace(/\\N/gi,"<br />");e.push(f("subtitle",o))}b.data=e;return b})})(Popcorn);(function(r){function f(b,e){var h=b.substr(10).split(","),i;i={start:n(h[e.start]),end:n(h[e.end])};if(i.start===-1||i.end===-1)throw"Invalid time";var j=q.call(m,/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,""),p=j.replace,m;m=h.length;q=[];for(var o=e.text;o<m;o++)q.push(h[o]);m=q.join(",");var q=m.replace;i.text=p.call(j,/\\N/gi,"<br />");return i}function n(b){var e=b.split(":");if(b.length!==10||e.length<3)return-1;return parseInt(e[0],10)*3600+parseInt(e[1],10)*60+parseFloat(e[2],10)}function c(b,
132
- e){var h={};h[b]=e;return h}r.parser("parseSSA",function(b){var e={title:"",remote:"",data:[]},h=[],i=0,j;b=b.text.split(/(?:\r\n|\r|\n)/gm);for(j=b.length;i<j&&b[i]!=="[Events]";)i++;var p=b[++i].substr(8).split(", "),m={},o,q;q=0;for(o=p.length;q<o;q++)if(p[q]==="Start")m.start=q;else if(p[q]==="End")m.end=q;else if(p[q]==="Text")m.text=q;for(;++i<j&&b[i]&&b[i][0]!=="[";)try{h.push(c("subtitle",f(b[i],m)))}catch(s){}e.data=h;return e})})(Popcorn);(function(r){function f(i,j,p){var m=i.firstChild;i=n(i,p);p=[];for(var o;m;){if(m.nodeType===1)if(m.nodeName==="p")p.push(c(m,j,i));else if(m.nodeName==="div"){o=b(m.getAttribute("begin"));if(o<0)o=j;p.push.apply(p,f(m,o,i))}m=m.nextSibling}return p}function n(i,j){var p=i.getAttribute("region");return p!==null?p:j||""}function c(i,j,p){var m={};m.text=(i.textContent||i.text).replace(e,"").replace(h,"<br />");m.id=i.getAttribute("xml:id")||i.getAttribute("id");m.start=b(i.getAttribute("begin"),j);
133
- m.end=b(i.getAttribute("end"),j);m.target=n(i,p);if(m.end<0){m.end=b(i.getAttribute("duration"),0);if(m.end>=0)m.end+=m.start;else m.end=Number.MAX_VALUE}return{subtitle:m}}function b(i,j){var p;if(!i)return-1;try{return r.util.toSeconds(i)}catch(m){for(var o=i.length-1;o>=0&&i[o]<="9"&&i[o]>="0";)o--;p=o;o=parseFloat(i.substring(0,p));p=i.substring(p);return o*({h:3600,m:60,s:1,ms:0.0010}[p]||-1)+(j||0)}}var e=/^[\s]+|[\s]+$/gm,h=/(?:\r\n|\r|\n)/gm;r.parser("parseTTML",function(i){var j={title:"",
134
- remote:"",data:[]};if(!i.xml||!i.xml.documentElement)return j;i=i.xml.documentElement.firstChild;if(!i)return j;for(;i.nodeName!=="body";)i=i.nextSibling;if(i)j.data=f(i,0);return j})})(Popcorn);(function(r){r.parser("parseTTXT",function(f){var n={title:"",remote:"",data:[]},c=function(j){j=j.split(":");var p=0;try{return parseFloat(j[0],10)*60*60+parseFloat(j[1],10)*60+parseFloat(j[2],10)}catch(m){p=0}return p},b=function(j,p){var m={};m[j]=p;return m};f=f.xml.lastChild.lastChild;for(var e=Number.MAX_VALUE,h=[];f;){if(f.nodeType===1&&f.nodeName==="TextSample"){var i={};i.start=c(f.getAttribute("sampleTime"));i.text=f.getAttribute("text");if(i.text){i.end=e-0.0010;h.push(b("subtitle",i))}e=
135
- i.start}f=f.previousSibling}n.data=h.reverse();return n})})(Popcorn);(function(r){function f(c){var b=c.split(":");c=c.length;var e;if(c!==12&&c!==9)throw"Bad cue";c=b.length-1;try{e=parseInt(b[c-1],10)*60+parseFloat(b[c],10);if(c===2)e+=parseInt(b[0],10)*3600}catch(h){throw"Bad cue";}return e}function n(c,b){var e={};e[c]=b;return e}r.parser("parseVTT",function(c){var b={title:"",remote:"",data:[]},e=[],h=0,i=0,j,p;c=c.text.split(/(?:\r\n|\r|\n)/gm);i=c.length;if(i===0||c[0]!=="WEBVTT")return b;for(h++;h<i;){j=[];try{for(var m=h;m<i&&!c[m];)m++;h=m;var o=c[h++];m=
136
- void 0;var q={};if(!o||o.indexOf("--\>")===-1)throw"Bad cue";m=o.replace(/--\>/," --\> ").split(/[\t ]+/);if(m.length<2)throw"Bad cue";q.id=o;q.start=f(m[0]);q.end=f(m[2]);for(p=q;h<i&&c[h];)j.push(c[h++]);p.text=j.join("<br />");e.push(n("subtitle",p))}catch(s){for(h=h;h<i&&c[h];)h++;h=h}}b.data=e;return b})})(Popcorn);(function(r){r.parser("parseXML","XML",function(f){var n={title:"",remote:"",data:[]},c={},b=function(m){m=m.split(":");if(m.length===1)return parseFloat(m[0],10);else if(m.length===2)return parseFloat(m[0],10)+parseFloat(m[1]/12,10);else if(m.length===3)return parseInt(m[0]*60,10)+parseFloat(m[1],10)+parseFloat(m[2]/12,10);else if(m.length===4)return parseInt(m[0]*3600,10)+parseInt(m[1]*60,10)+parseFloat(m[2],10)+parseFloat(m[3]/12,10)},e=function(m){for(var o={},q=0,s=m.length;q<s;q++){var d=m.item(q).nodeName,
137
- A=m.item(q).nodeValue,y=c[A];if(d==="in")o.start=b(A);else if(d==="out")o.end=b(A);else if(d==="resourceid")for(var x in y){if(y.hasOwnProperty(x))if(!o[x]&&x!=="id")o[x]=y[x]}else o[d]=A}return o},h=function(m,o){var q={};q[m]=o;return q},i=function(m,o,q){var s={};r.extend(s,o,e(m.attributes),{text:m.textContent||m.text});o=m.childNodes;if(o.length<1||o.length===1&&o[0].nodeType===3)if(q)c[s.id]=s;else n.data.push(h(m.nodeName,s));else for(m=0;m<o.length;m++)o[m].nodeType===1&&i(o[m],s,q)};f=f.documentElement.childNodes;
138
- for(var j=0,p=f.length;j<p;j++)if(f[j].nodeType===1)f[j].nodeName==="manifest"?i(f[j],{},true):i(f[j],{},false);return n})})(Popcorn);(function(){var r=false,f=false;Popcorn.player("soundcloud",{_canPlayType:function(n,c){return/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(soundcloud)/.test(c)&&n.toLowerCase()!=="video"},_setup:function(n){function c(){r=true;SC.initialize({client_id:"PRaNFlda6Bhf5utPjUsptg"});SC.get("/resolve",{url:e.src},function(A){e.width=e.style.width?""+e.offsetWidth:"560";e.height=e.style.height?""+e.offsetHeight:"315";h.scrolling="no";h.frameborder="no";h.id="soundcloud-"+Popcorn.guid();h.src="http://w.soundcloud.com/player/?url="+
139
- A.uri+"&show_artwork=false&buying=false&liking=false&sharing=false";h.width="100%";h.height="100%";n.loadListener=function(){n.widget=o=SC.Widget(h.id);o.bind(SC.Widget.Events.FINISH,function(){e.pause();e.dispatchEvent("ended")});o.bind(SC.Widget.Events.PLAY_PROGRESS,function(y){j=y.currentPosition/1E3;e.dispatchEvent("timeupdate")});o.bind(SC.Widget.Events.PLAY,function(){p=m=false;e.dispatchEvent("play");e.dispatchEvent("playing");e.currentTime=j;d.next()});o.bind(SC.Widget.Events.PAUSE,function(){p=
140
- m=true;e.dispatchEvent("pause");d.next()});o.bind(SC.Widget.Events.READY,function(){o.getDuration(function(y){q=y/1E3;e.style.visibility="visible";e.dispatchEvent("durationchange");e.readyState=4;e.dispatchEvent("readystatechange");e.dispatchEvent("loadedmetadata");e.dispatchEvent("loadeddata");e.dispatchEvent("canplaythrough");e.dispatchEvent("load");!e.paused&&e.play()});o.getVolume(function(y){i=y/100})})};h.addEventListener("load",n.loadListener,false);e.appendChild(h)})}function b(){if(f)(function A(){setTimeout(function(){r?
141
- c():A()},100)})();else{f=true;Popcorn.getScript("http://w.soundcloud.com/player/api.js",function(){Popcorn.getScript("http://connect.soundcloud.com/sdk.js",function(){c()})})}}var e=this,h=document.createElement("iframe"),i=1,j=0,p=true,m=true,o,q=0,s=false,d=Popcorn.player.playerQueue();n._container=h;e.style.visibility="hidden";e.play=function(){p=false;d.add(function(){if(m)o&&o.play();else d.next()})};e.pause=function(){p=true;d.add(function(){if(m)d.next();else o&&o.pause()})};Object.defineProperties(e,
142
- {muted:{set:function(A){if(A){o&&o.getVolume(function(y){i=y/100});o&&o.setVolume(0);s=true}else{o&&o.setVolume(i*100);s=false}e.dispatchEvent("volumechange")},get:function(){return s}},volume:{set:function(A){o&&o.setVolume(A*100);i=A;e.dispatchEvent("volumechange")},get:function(){return s?0:i}},currentTime:{set:function(A){j=A;o&&o.seekTo(A*1E3);e.dispatchEvent("seeked");e.dispatchEvent("timeupdate")},get:function(){return j}},duration:{get:function(){return q}},paused:{get:function(){return p}}});
143
- r?c():b()},_teardown:function(n){var c=n.widget,b=SC.Widget.Events,e=n._container;n.destroyed=true;if(c)for(var h in b)c&&c.unbind(b[h]);else e.removeEventListener("load",n.loadEventListener,false)}})})();(function(){function r(n){var c=r.options;n=c.parser[c.strictMode?"strict":"loose"].exec(n);for(var b={},e=14;e--;)b[c.key[e]]=n[e]||"";b[c.q.name]={};b[c.key[12]].replace(c.q.parser,function(h,i,j){if(i)b[c.q.name][i]=j});return b}function f(n,c){return/player.vimeo.com\/video\/\d+/.test(c)||/vimeo.com\/\d+/.test(c)}r.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",
144
- parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};Popcorn.player("vimeo",{_canPlayType:f,_setup:function(n){function c(l,k){var t=y.src.split("?")[0],u=JSON.stringify({method:l,
145
- value:k});if(t.substr(0,2)==="//")t=window.location.protocol+t;y.contentWindow?y.contentWindow.postMessage(u,t):o.unload()}function b(l){if(l.origin==="http://player.vimeo.com"){var k;try{k=JSON.parse(l.data)}catch(t){console.warn(t)}if(k.player_id==m){k.method&&a[k.method]&&a[k.method](k);k.event&&g[k.event]&&g[k.event](k)}}}function e(){d||(d=setInterval(function(){o.dispatchEvent("timeupdate")},i));s||(s=setInterval(function(){c("getCurrentTime")},j))}function h(){if(d){clearInterval(d);d=0}if(s){clearInterval(s);
146
- s=0}}var i=250,j=16,p={MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4},m,o=this,q={q:[],queue:function(l){this.q.push(l);this.process()},process:function(){if(A)for(;this.q.length;)this.q.shift()()}},s,d,A,y=document.createElement("iframe"),x={error:null,src:o.src,NETWORK_EMPTY:0,NETWORK_IDLE:1,NETWORK_LOADING:2,NETWORK_NO_SOURCE:3,networkState:0,HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4,readyState:0,seeking:false,
147
- currentTime:0,duration:NaN,paused:true,ended:false,autoplay:false,loop:false,volume:1,muted:false,width:0,height:0};Popcorn.forEach("error networkState readyState seeking duration paused ended".split(" "),function(l){Object.defineProperty(o,l,{get:function(){return x[l]}})});Object.defineProperties(o,{src:{get:function(){return x.src},set:function(l){x.src=l;o.load()}},currentTime:{get:function(){return x.currentTime},set:function(l){q.queue(function(){c("seekTo",l)});x.seeking=true;o.dispatchEvent("seeking")}},
148
- autoplay:{get:function(){return x.autoplay},set:function(l){x.autoplay=!!l}},loop:{get:function(){return x.loop},set:function(l){x.loop=!!l;q.queue(function(){c("setLoop",loop)})}},volume:{get:function(){return x.volume},set:function(l){x.volume=l;q.queue(function(){c("setVolume",x.muted?0:x.volume)});o.dispatchEvent("volumechange")}},muted:{get:function(){return x.muted},set:function(l){x.muted=!!l;q.queue(function(){c("setVolume",x.muted?0:x.volume)});o.dispatchEvent("volumechange")}},width:{get:function(){return y.width},
149
- set:function(l){y.width=l}},height:{get:function(){return y.height},set:function(l){y.height=l}}});var a={getCurrentTime:function(l){x.currentTime=parseFloat(l.value)},getDuration:function(l){x.duration=parseFloat(l.value);if(!isNaN(x.duration)){x.readyState=4;o.dispatchEvent("durationchange");o.dispatchEvent("loadedmetadata");o.dispatchEvent("loadeddata");o.dispatchEvent("canplay");o.dispatchEvent("canplaythrough")}},getVolume:function(l){x.volume=parseFloat(l.value)}},g={ready:function(){c("addEventListener",
150
- "loadProgress");c("addEventListener","playProgress");c("addEventListener","play");c("addEventListener","pause");c("addEventListener","finish");c("addEventListener","seek");c("getDuration");A=true;q.process();o.dispatchEvent("loadstart")},loadProgress:function(l){o.dispatchEvent("progress");x.duration=parseFloat(l.data.duration)},playProgress:function(l){x.currentTime=parseFloat(l.data.seconds)},play:function(){if(x.seeking){x.seeking=false;o.dispatchEvent("seeked")}x.paused=false;x.ended=false;e();
151
- o.dispatchEvent("play")},pause:function(){x.paused=true;h();o.dispatchEvent("pause")},finish:function(){x.ended=true;h();o.dispatchEvent("ended")},seek:function(l){x.currentTime=parseFloat(l.data.seconds);x.seeking=false;x.ended=false;o.dispatchEvent("timeupdate");o.dispatchEvent("seeked")}};o.load=function(){A=false;m=Popcorn.guid();var l=r(x.src),k={},t=[],u={api:1,player_id:m};if(f(o.nodeName,l.source)){Popcorn.extend(k,n);Popcorn.extend(k,l.queryKey);Popcorn.extend(k,u);l="http://player.vimeo.com/video/"+
152
- /\d+$/.exec(l.path)+"?";for(var v in k)k.hasOwnProperty(v)&&t.push(encodeURIComponent(v)+"="+encodeURIComponent(k[v]));l+=t.join("&");x.loop=!!l.match(/loop=1/);x.autoplay=!!l.match(/autoplay=1/);y.width=o.style.width?o.style.width:500;y.height=o.style.height?o.style.height:281;y.frameBorder=0;y.webkitAllowFullScreen=true;y.mozAllowFullScreen=true;y.allowFullScreen=true;y.src=l;o.appendChild(y)}else{l=x.MEDIA_ERR_SRC_NOT_SUPPORTED;x.error={};Popcorn.extend(x.error,p);x.error.code=l;o.dispatchEvent("error")}};
153
- o.unload=function(){h();window.removeEventListener("message",b,false)};o.play=function(){q.queue(function(){c("play")})};o.pause=function(){q.queue(function(){c("pause")})};setTimeout(function(){window.addEventListener("message",b,false);o.load()},0)},_teardown:function(){this.unload&&this.unload()}})})();(function(r,f){r.onYouTubePlayerAPIReady=function(){onYouTubePlayerAPIReady.ready=true;for(var c=0;c<onYouTubePlayerAPIReady.waiting.length;c++)onYouTubePlayerAPIReady.waiting[c]()};if(r.YT){r.quarantineYT=r.YT;r.YT=null}onYouTubePlayerAPIReady.waiting=[];var n=false;f.player("youtube",{_canPlayType:function(c,b){return typeof b==="string"&&/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(youtu)/.test(b)&&c.toLowerCase()!=="video"},_setup:function(c){if(!r.YT&&!n){n=true;f.getScript("//youtube.com/player_api")}var b=
154
- this,e=false,h=document.createElement("div"),i=0,j=true,p=false,m=0,o=false,q=100,s=f.player.playerQueue(),d=function(){f.player.defineProperty(b,"currentTime",{set:function(y){if(!c.destroyed){p=true;i=Math.round(+y*100)/100}},get:function(){return i}});f.player.defineProperty(b,"paused",{get:function(){return j}});f.player.defineProperty(b,"muted",{set:function(y){if(c.destroyed)return y;if(c.youtubeObject.isMuted()!==y){y?c.youtubeObject.mute():c.youtubeObject.unMute();o=c.youtubeObject.isMuted();
155
- b.dispatchEvent("volumechange")}return c.youtubeObject.isMuted()},get:function(){if(c.destroyed)return 0;return c.youtubeObject.isMuted()}});f.player.defineProperty(b,"volume",{set:function(y){if(c.destroyed)return y;if(c.youtubeObject.getVolume()/100!==y){c.youtubeObject.setVolume(y*100);q=c.youtubeObject.getVolume();b.dispatchEvent("volumechange")}return c.youtubeObject.getVolume()/100},get:function(){if(c.destroyed)return 0;return c.youtubeObject.getVolume()/100}});b.play=function(){if(!c.destroyed){j=
156
- false;s.add(function(){if(c.youtubeObject.getPlayerState()!==1){p=false;c.youtubeObject.playVideo()}else s.next()})}};b.pause=function(){if(!c.destroyed){j=true;s.add(function(){c.youtubeObject.getPlayerState()!==2?c.youtubeObject.pauseVideo():s.next()})}}};h.id=b.id+f.guid();c._container=h;b.appendChild(h);var A=function(){var y,x,a,g,l=true,k=function(){if(!c.destroyed){if(p)if(i===c.youtubeObject.getCurrentTime()){p=false;b.dispatchEvent("seeked");b.dispatchEvent("timeupdate")}else c.youtubeObject.seekTo(i);
157
- else{i=c.youtubeObject.getCurrentTime();b.dispatchEvent("timeupdate")}setTimeout(k,250)}},t=function(z){var C=c.youtubeObject.getDuration();if(isNaN(C)||C===0)setTimeout(function(){t(z*2)},z*1E3);else{b.duration=C;b.dispatchEvent("durationchange");b.dispatchEvent("loadedmetadata");b.dispatchEvent("loadeddata");b.readyState=4;k();b.dispatchEvent("canplaythrough")}};c.controls=+c.controls===0||+c.controls===1?c.controls:1;c.annotations=+c.annotations===1||+c.annotations===3?c.annotations:1;y=/^.*(?:\/|v=)(.{11})/.exec(b.src)[1];
158
- x=(b.src.split("?")[1]||"").replace(/v=.{11}/,"");x=x.replace(/&t=(?:(\d+)m)?(?:(\d+)s)?/,function(z,C,E){C|=0;E|=0;m=+E+C*60;return""});x=x.replace(/&start=(\d+)?/,function(z,C){C|=0;m=C;return""});e=/autoplay=1/.test(x);x=x.split(/[\&\?]/g);a={wmode:"transparent"};for(var u=0;u<x.length;u++){g=x[u].split("=");a[g[0]]=g[1]}c.youtubeObject=new YT.Player(h.id,{height:"100%",width:"100%",wmode:"transparent",playerVars:a,videoId:y,events:{onReady:function(){q=b.volume;o=b.muted;v();j=b.paused;d();c.youtubeObject.playVideo();
159
- b.currentTime=m},onStateChange:function(z){if(!(c.destroyed||z.data===-1))if(z.data===2){j=true;b.dispatchEvent("pause");s.next()}else if(z.data===1&&!l){j=false;b.dispatchEvent("play");b.dispatchEvent("playing");s.next()}else if(z.data===0)b.dispatchEvent("ended");else if(z.data===1&&l){l=false;if(e||!b.paused)j=false;j&&c.youtubeObject.pauseVideo();t(0.025)}},onError:function(z){if([2,100,101,150].indexOf(z.data)!==-1){b.error={customCode:z.data};b.dispatchEvent("error")}}}});var v=function(){if(!c.destroyed){if(o!==
160
- c.youtubeObject.isMuted()){o=c.youtubeObject.isMuted();b.dispatchEvent("volumechange")}if(q!==c.youtubeObject.getVolume()){q=c.youtubeObject.getVolume();b.dispatchEvent("volumechange")}setTimeout(v,250)}}};onYouTubePlayerAPIReady.ready?A():onYouTubePlayerAPIReady.waiting.push(A)},_teardown:function(c){c.destroyed=true;var b=c.youtubeObject;if(b){b.stopVideo();b.clearVideo&&b.clearVideo()}this.removeChild(document.getElementById(c._container.id))}})})(window,Popcorn);
146
+ "default":"Toronto, Ontario, Canada"},markers:{elem:"input",type:"text",label:"List Markers",optional:true}}})})(Popcorn);var wikiCallback;
147
+ (function(p){p.plugin("wikipedia",{manifest:{about:{name:"Popcorn Wikipedia Plugin",version:"0.1",author:"@annasob",website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},lang:{elem:"input",type:"text",label:"Language","default":"english",optional:true},src:{elem:"input",type:"url",label:"Wikipedia URL","default":"http://en.wikipedia.org/wiki/Cat"},title:{elem:"input",type:"text",label:"Title","default":"Cats",optional:true},
148
+ numberofwords:{elem:"input",type:"number",label:"Number of Words","default":"200",optional:true},target:"wikipedia-container"}},_setup:function(e){var l,d=p.guid();if(!e.lang)e.lang="en";e.numberofwords=e.numberofwords||200;window["wikiCallback"+d]=function(b){e._link=document.createElement("a");e._link.setAttribute("href",e.src);e._link.setAttribute("target","_blank");e._link.innerHTML=e.title||b.parse.displaytitle;e._desc=document.createElement("p");l=b.parse.text["*"].substr(b.parse.text["*"].indexOf("<p>"));
149
+ l=l.replace(/((<(.|\n)+?>)|(\((.*?)\) )|(\[(.*?)\]))/g,"");l=l.split(" ");e._desc.innerHTML=l.slice(0,l.length>=e.numberofwords?e.numberofwords:l.length).join(" ")+" ...";e._fired=true};e.src&&p.getScript("//"+e.lang+".wikipedia.org/w/api.php?action=parse&props=text&redirects&page="+e.src.slice(e.src.lastIndexOf("/")+1)+"&format=json&callback=wikiCallback"+d);e.toString=function(){return e.src||e._natives.manifest.options.src["default"]}},start:function(e,l){var d=function(){if(l._fired){if(l._link&&
150
+ l._desc)if(document.getElementById(l.target)){document.getElementById(l.target).appendChild(l._link);document.getElementById(l.target).appendChild(l._desc);l._added=true}}else setTimeout(function(){d()},13)};d()},end:function(e,l){if(l._added){document.getElementById(l.target).removeChild(l._link);document.getElementById(l.target).removeChild(l._desc)}},_teardown:function(e){if(e._added){e._link.parentNode&&document.getElementById(e.target).removeChild(e._link);e._desc.parentNode&&document.getElementById(e.target).removeChild(e._desc);
151
+ delete e.target}}})})(Popcorn);(function(p){var e=0,l=function(d,b){var h=d.container=document.createElement("div"),i=h.style,g=d.media,k=function(){var r=d.position();i.fontSize="18px";i.width=g.offsetWidth+"px";i.top=r.top+g.offsetHeight-h.offsetHeight-40+"px";i.left=r.left+"px";setTimeout(k,10)};h.id=b||p.guid();i.position="absolute";i.color="white";i.textShadow="black 2px 2px 6px";i.fontWeight="bold";i.textAlign="center";k();d.media.parentNode.appendChild(h);return h};p.plugin("subtitle",{manifest:{about:{name:"Popcorn Subtitle Plugin",
152
+ version:"0.1",author:"Scott Downe",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"text",label:"Start"},end:{elem:"input",type:"text",label:"End"},target:"subtitle-container",text:{elem:"input",type:"text",label:"Text"}}},_setup:function(d){var b=document.createElement("div");b.id="subtitle-"+e++;b.style.display="none";!this.container&&(!d.target||d.target==="subtitle-container")&&l(this);d.container=d.target&&d.target!=="subtitle-container"?document.getElementById(d.target)||
153
+ l(this,d.target):this.container;document.getElementById(d.container.id)&&document.getElementById(d.container.id).appendChild(b);d.innerContainer=b;d.showSubtitle=function(){d.innerContainer.innerHTML=d.text||""}},start:function(d,b){b.innerContainer.style.display="inline";b.showSubtitle(b,b.text)},end:function(d,b){b.innerContainer.style.display="none";b.innerContainer.innerHTML=""},_teardown:function(d){d.container.removeChild(d.innerContainer)}})})(Popcorn);(function(p,e){var l={};p.plugin("documentcloud",{manifest:{about:{name:"Popcorn Document Cloud Plugin",version:"0.1",author:"@humphd, @ChrisDeCairos",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"documentcloud-container",width:{elem:"input",type:"text",label:"Width",optional:true},height:{elem:"input",type:"text",label:"Height",optional:true},src:{elem:"input",type:"url",label:"PDF URL","default":"http://www.documentcloud.org/documents/70050-urbina-day-1-in-progress.html"},
154
+ preload:{elem:"input",type:"checkbox",label:"Preload","default":true},page:{elem:"input",type:"number",label:"Page Number",optional:true},aid:{elem:"input",type:"number",label:"Annotation Id",optional:true}}},_setup:function(d){function b(){function m(j){d._key=j.api.getId();d._changeView=function(w){d.aid?w.pageSet.showAnnotation(w.api.getAnnotation(d.aid)):w.api.setCurrentPage(d.page)}}function t(){l[d._key]={num:1,id:d._containerId};i.loaded=true}i.loaded=false;var q=d.url.replace(/\.html$/,".js"),
155
+ o=d.target,u=e.getElementById(o),E=e.createElement("div"),C=p.position(u),f=d.width||C.width;C=d.height||C.height;var G=d.sidebar||true,A=d.text||true,O=d.pdf||true,a=d.showAnnotations||true,c=d.zoom||700,n=d.search||true;if(!function(j){var w=false;p.forEach(i.viewers,function(x){if(x.api.getSchema().canonicalURL===j){m(x);x=l[d._key];d._containerId=x.id;x.num+=1;w=true;i.loaded=true}});return w}(d.url)){E.id=d._containerId=p.guid(o);o="#"+E.id;u.appendChild(E);g.trigger("documentready");i.load(q,
156
+ {width:f,height:C,sidebar:G,text:A,pdf:O,showAnnotations:a,zoom:c,search:n,container:o,afterLoad:d.page||d.aid?function(j){m(j);d._changeView(j);E.style.visibility="hidden";j.elements.pages.hide();t()}:function(j){m(j);t();E.style.visibility="hidden";j.elements.pages.hide()}})}}function h(){window.DV.loaded?b():setTimeout(h,25)}var i=window.DV=window.DV||{},g=this;if(i.loading)h();else{i.loading=true;i.recordHit="//www.documentcloud.org/pixel.gif";var k=e.createElement("link"),r=e.getElementsByTagName("head")[0];
157
+ k.rel="stylesheet";k.type="text/css";k.media="screen";k.href="//s3.documentcloud.org/viewer/viewer-datauri.css";r.appendChild(k);i.loaded=false;p.getScript("http://s3.documentcloud.org/viewer/viewer.js",function(){i.loading=false;b()})}d.toString=function(){return d.src||d._natives.manifest.options.src["default"]}},start:function(d,b){var h=e.getElementById(b._containerId),i=DV.viewers[b._key];(b.page||b.aid)&&i&&b._changeView(i);if(h&&i){h.style.visibility="visible";i.elements.pages.show()}},end:function(d,
158
+ b){var h=e.getElementById(b._containerId);if(h&&DV.viewers[b._key]){h.style.visibility="hidden";DV.viewers[b._key].elements.pages.hide()}},_teardown:function(d){var b=e.getElementById(d._containerId);if((d=d._key)&&DV.viewers[d]&&--l[d].num===0){for(DV.viewers[d].api.unload();b.hasChildNodes();)b.removeChild(b.lastChild);b.parentNode.removeChild(b)}}})})(Popcorn,window.document);(function(p){var e=/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(youtu|vimeo|soundcloud|baseplayer)/,l={},d={vimeo:false,youtube:false,soundcloud:false,module:false};Object.defineProperty(l,void 0,{get:function(){return d[void 0]},set:function(b){d[void 0]=b}});p.plugin("mediaspawner",{manifest:{about:{name:"Popcorn Media Spawner Plugin",version:"0.1",author:"Matthew Schranz, @mjschranz",website:"mschranz.wordpress.com"},options:{source:{elem:"input",type:"text",label:"Media Source","default":"http://www.youtube.com/watch?v=CXDstfD9eJ0"},
159
+ caption:{elem:"input",type:"text",label:"Media Caption","default":"Popcorn Popping",optional:true},target:"mediaspawner-container",start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},autoplay:{elem:"input",type:"checkbox",label:"Autoplay Video",optional:true},width:{elem:"input",type:"number",label:"Media Width","default":400,units:"px",optional:true},height:{elem:"input",type:"number",label:"Media Height","default":200,units:"px",optional:true}}},_setup:function(b){function h(){function t(){if(k!==
160
+ "HTML5"&&!window.Popcorn[k])setTimeout(function(){t()},300);else{b.id=b._container.id;b._container.style.width=b.width+"px";b._container.style.height=b.height+"px";b.popcorn=p.smart("#"+b.id,b.source);k==="HTML5"&&b.popcorn.controls(true);b._container.style.width="0px";b._container.style.height="0px";b._container.style.visibility="hidden";b._container.style.overflow="hidden"}}if(k!=="HTML5"&&!window.Popcorn[k]&&!l[k]){l[k]=true;p.getScript("http://popcornjs.org/code/players/"+k+"/popcorn."+k+".js",
161
+ function(){t()})}else t()}function i(){window.Popcorn.player?h():setTimeout(function(){i()},300)}var g=document.getElementById(b.target)||{},k,r,m;if(r=e.exec(b.source)){k=r[1];if(k==="youtu")k="youtube"}else k="HTML5";b._type=k;b._container=document.createElement("div");r=b._container;r.id="mediaSpawnerdiv-"+p.guid();b.width=b.width||400;b.height=b.height||200;if(b.caption){m=document.createElement("div");m.innerHTML=b.caption;m.style.display="none";b._capCont=m;r.appendChild(m)}g&&g.appendChild(r);
162
+ if(!window.Popcorn.player&&!l.module){l.module=true;p.getScript("http://popcornjs.org/code/modules/player/popcorn.player.js",i)}else i();b.toString=function(){return b.source||b._natives.manifest.options.source["default"]}},start:function(b,h){if(h._capCont)h._capCont.style.display="";h._container.style.width=h.width+"px";h._container.style.height=h.height+"px";h._container.style.visibility="visible";h._container.style.overflow="visible";h.autoplay&&h.popcorn.play()},end:function(b,h){if(h._capCont)h._capCont.style.display=
163
+ "none";h._container.style.width="0px";h._container.style.height="0px";h._container.style.visibility="hidden";h._container.style.overflow="hidden";h.popcorn.pause()},_teardown:function(b){b.popcorn&&b.popcorn.destory&&b.popcorn.destroy();document.getElementById(b.target)&&document.getElementById(b.target).removeChild(b._container)}})})(Popcorn,this);(function(p){var e=1;p.plugin("timeline",function(l){var d=document.getElementById(l.target),b=document.createElement("div"),h,i=true;if(d&&!d.firstChild){d.appendChild(h=document.createElement("div"));h.style.width="inherit";h.style.height="inherit";h.style.overflow="auto"}else h=d.firstChild;b.style.display="none";b.id="timelineDiv"+e;l.direction=l.direction||"up";if(l.direction.toLowerCase()==="down")i=false;if(d&&h)i?h.insertBefore(b,h.firstChild):h.appendChild(b);e++;b.innerHTML="<p><span id='big' style='font-size:24px; line-height: 130%;' >"+
164
+ l.title+"</span><br /><span id='mid' style='font-size: 16px;'>"+l.text+"</span><br />"+l.innerHTML;return{start:function(g,k){b.style.display="block";if(k.direction==="down")h.scrollTop=h.scrollHeight},end:function(){b.style.display="none"},_teardown:function(){h&&b&&h.removeChild(b)&&!h.firstChild&&d.removeChild(h)}}},{about:{name:"Popcorn Timeline Plugin",version:"0.1",author:"David Seifried @dcseifried",website:"dseifried.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},
165
+ end:{elem:"input",type:"number",label:"End"},target:"feed-container",title:{elem:"input",type:"text",label:"Title"},text:{elem:"input",type:"text",label:"Text"},innerHTML:{elem:"input",type:"text",label:"HTML Code",optional:true},direction:{elem:"select",options:["DOWN","UP"],label:"Direction",optional:true}}})})(Popcorn);(function(p){var e=0;p.plugin("flickr",function(l){var d,b=document.getElementById(l.target),h,i,g,k,r=l.numberofimages||4,m=l.height||"50px",t=l.width||"50px",q=l.padding||"5px",o=l.border||"0px";d=document.createElement("div");d.id="flickr"+e;d.style.width="100%";d.style.height="100%";d.style.display="none";e++;b&&b.appendChild(d);var u=function(){if(h)setTimeout(function(){u()},5);else{i="http://api.flickr.com/services/rest/?method=flickr.people.findByUsername&";i+="username="+l.username+"&api_key="+
166
+ l.apikey+"&format=json&jsoncallback=flickr";p.getJSONP(i,function(C){h=C.user.nsid;E()})}},E=function(){i="http://api.flickr.com/services/feeds/photos_public.gne?";if(h)i+="id="+h+"&";if(l.tags)i+="tags="+l.tags+"&";i+="lang=en-us&format=json&jsoncallback=flickr";p.xhr.getJSONP(i,function(C){var f=document.createElement("div");f.innerHTML="<p style='padding:"+q+";'>"+C.title+"<p/>";p.forEach(C.items,function(G,A){if(A<r){g=document.createElement("a");g.setAttribute("href",G.link);g.setAttribute("target",
167
+ "_blank");k=document.createElement("img");k.setAttribute("src",G.media.m);k.setAttribute("height",m);k.setAttribute("width",t);k.setAttribute("style","border:"+o+";padding:"+q);g.appendChild(k);f.appendChild(g)}else return false});d.appendChild(f)})};if(l.username&&l.apikey)u();else{h=l.userid;E()}l.toString=function(){return l.tags||l.username||"Flickr"};return{start:function(){d.style.display="inline"},end:function(){d.style.display="none"},_teardown:function(C){document.getElementById(C.target)&&
168
+ document.getElementById(C.target).removeChild(d)}}},{about:{name:"Popcorn Flickr Plugin",version:"0.2",author:"Scott Downe, Steven Weerdenburg, Annasob",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},userid:{elem:"input",type:"text",label:"User ID",optional:true},tags:{elem:"input",type:"text",label:"Tags"},username:{elem:"input",type:"text",label:"Username",optional:true},apikey:{elem:"input",type:"text",
169
+ label:"API Key",optional:true},target:"flickr-container",height:{elem:"input",type:"text",label:"Height","default":"50px",optional:true},width:{elem:"input",type:"text",label:"Width","default":"50px",optional:true},padding:{elem:"input",type:"text",label:"Padding",optional:true},border:{elem:"input",type:"text",label:"Border","default":"5px",optional:true},numberofimages:{elem:"input",type:"number","default":4,label:"Number of Images"}}})})(Popcorn);(function(p){p.plugin("webpage",{manifest:{about:{name:"Popcorn Webpage Plugin",version:"0.1",author:"@annasob",website:"annasob.wordpress.com"},options:{id:{elem:"input",type:"text",label:"Id",optional:true},start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},src:{elem:"input",type:"url",label:"Webpage URL","default":"http://mozillapopcorn.org"},target:"iframe-container"}},_setup:function(e){var l=document.getElementById(e.target);e.src=e.src.replace(/^(https?:)?(\/\/)?/,
170
+ "//");e._iframe=document.createElement("iframe");e._iframe.setAttribute("width","100%");e._iframe.setAttribute("height","100%");e._iframe.id=e.id;e._iframe.src=e.src;e._iframe.style.display="none";l&&l.appendChild(e._iframe)},start:function(e,l){l._iframe.src=l.src;l._iframe.style.display="inline"},end:function(e,l){l._iframe.style.display="none"},_teardown:function(e){document.getElementById(e.target)&&document.getElementById(e.target).removeChild(e._iframe)}})})(Popcorn);(function(p){var e={},l=0,d=document.createElement("span"),b=["webkit","Moz","ms","O",""],h=["Transform","TransitionDuration","TransitionTimingFunction"],i={},g;document.getElementsByTagName("head")[0].appendChild(d);for(var k=0,r=h.length;k<r;k++)for(var m=0,t=b.length;m<t;m++){g=b[m]+h[k];if(g in d.style){i[h[k].toLowerCase()]=g;break}}document.getElementsByTagName("head")[0].appendChild(d);p.plugin("wordriver",{manifest:{about:{name:"Popcorn WordRiver Plugin"},options:{start:{elem:"input",type:"number",
171
+ label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"wordriver-container",text:{elem:"input",type:"text",label:"Text","default":"Popcorn.js"},color:{elem:"input",type:"text",label:"Color","default":"Green",optional:true}}},_setup:function(q){q._duration=q.end-q.start;var o;if(!(o=e[q.target])){o=q.target;e[o]=document.createElement("div");var u=document.getElementById(o);u&&u.appendChild(e[o]);e[o].style.height="100%";e[o].style.position="relative";o=e[o]}q._container=o;q.word=document.createElement("span");
172
+ q.word.style.position="absolute";q.word.style.whiteSpace="nowrap";q.word.style.opacity=0;q.word.style.MozTransitionProperty="opacity, -moz-transform";q.word.style.webkitTransitionProperty="opacity, -webkit-transform";q.word.style.OTransitionProperty="opacity, -o-transform";q.word.style.transitionProperty="opacity, transform";q.word.style[i.transitionduration]="1s, "+q._duration+"s";q.word.style[i.transitiontimingfunction]="linear";q.word.innerHTML=q.text;q.word.style.color=q.color||"black"},start:function(q,
173
+ o){o._container.appendChild(o.word);o.word.style[i.transform]="";o.word.style.fontSize=~~(30+20*Math.random())+"px";l%=o._container.offsetWidth-o.word.offsetWidth;o.word.style.left=l+"px";l+=o.word.offsetWidth+10;o.word.style[i.transform]="translateY("+(o._container.offsetHeight-o.word.offsetHeight)+"px)";o.word.style.opacity=1;setTimeout(function(){o.word.style.opacity=0},(o.end-o.start-1||1)*1E3)},end:function(q,o){o.word.style.opacity=0},_teardown:function(q){var o=document.getElementById(q.target);
174
+ q.word.parentNode&&q._container.removeChild(q.word);e[q.target]&&!e[q.target].childElementCount&&o&&o.removeChild(e[q.target])&&delete e[q.target]}})})(Popcorn);var googleCallback;
175
+ (function(p){function e(g,k,r){g=g.type?g.type.toUpperCase():"HYBRID";var m;if(g==="STAMEN-WATERCOLOR"||g==="STAMEN-TERRAIN"||g==="STAMEN-TONER")m=g.replace("STAMEN-","").toLowerCase();r=new google.maps.Map(r,{mapTypeId:m?m:google.maps.MapTypeId[g],mapTypeControlOptions:{mapTypeIds:[]}});m&&r.mapTypes.set(m,new google.maps.StamenMapType(m));r.getDiv().style.display="none";return r}var l=1,d=false,b=false,h,i;googleCallback=function(g){if(typeof google!=="undefined"&&google.maps&&google.maps.Geocoder&&
176
+ google.maps.LatLng){h=new google.maps.Geocoder;p.getScript("//maps.stamen.com/js/tile.stamen.js",function(){b=true})}else setTimeout(function(){googleCallback(g)},1)};i=function(){if(document.body){d=true;p.getScript("//maps.google.com/maps/api/js?sensor=false&callback=googleCallback")}else setTimeout(function(){i()},1)};p.plugin("googlemap",function(g){var k,r,m,t=document.getElementById(g.target);g.type=g.type||"ROADMAP";g.zoom=g.zoom||1;g.lat=g.lat||0;g.lng=g.lng||0;d||i();k=document.createElement("div");
177
+ k.id="actualmap"+l;k.style.width=g.width||"100%";k.style.height=g.height?g.height:t&&t.clientHeight?t.clientHeight+"px":"100%";l++;t&&t.appendChild(k);var q=function(){if(b){if(k)if(g.location)h.geocode({address:g.location},function(o,u){if(k&&u===google.maps.GeocoderStatus.OK){g.lat=o[0].geometry.location.lat();g.lng=o[0].geometry.location.lng();m=new google.maps.LatLng(g.lat,g.lng);r=e(g,m,k)}});else{m=new google.maps.LatLng(g.lat,g.lng);r=e(g,m,k)}}else setTimeout(function(){q()},5)};q();g.toString=
178
+ function(){return g.location||(g.lat&&g.lng?g.lat+", "+g.lng:g._natives.manifest.options.location["default"])};return{start:function(o,u){var E=this,C,f=function(){if(r){u._map=r;r.getDiv().style.display="block";google.maps.event.trigger(r,"resize");r.setCenter(m);if(u.zoom&&typeof u.zoom!=="number")u.zoom=+u.zoom;r.setZoom(u.zoom);if(u.heading&&typeof u.heading!=="number")u.heading=+u.heading;if(u.pitch&&typeof u.pitch!=="number")u.pitch=+u.pitch;if(u.type==="STREETVIEW"){r.setStreetView(C=new google.maps.StreetViewPanorama(k,
179
+ {position:m,pov:{heading:u.heading=u.heading||0,pitch:u.pitch=u.pitch||0,zoom:u.zoom}}));var G=function(w,x){var z=google.maps.geometry.spherical.computeHeading;setTimeout(function(){var F=E.media.currentTime;if(typeof u.tween==="object"){for(var v=0,L=w.length;v<L;v++){var y=w[v];if(F>=y.interval*(v+1)/1E3&&(F<=y.interval*(v+2)/1E3||F>=y.interval*L/1E3)){n.setPosition(new google.maps.LatLng(y.position.lat,y.position.lng));n.setPov({heading:y.pov.heading||z(y,w[v+1])||0,zoom:y.pov.zoom||0,pitch:y.pov.pitch||
180
+ 0})}}G(w,w[0].interval)}else{v=0;for(L=w.length;v<L;v++){y=u.interval;if(F>=y*(v+1)/1E3&&(F<=y*(v+2)/1E3||F>=y*L/1E3)){A.setPov({heading:z(w[v],w[v+1])||0,zoom:u.zoom,pitch:u.pitch||0});A.setPosition(O[v])}}G(O,u.interval)}},x)};if(u.location&&typeof u.tween==="string"){var A=C,O=[],a=new google.maps.DirectionsService,c=new google.maps.DirectionsRenderer(A);a.route({origin:u.location,destination:u.tween,travelMode:google.maps.TravelMode.DRIVING},function(w,x){if(x==google.maps.DirectionsStatus.OK){c.setDirections(w);
181
+ for(var z=w.routes[0].overview_path,F=0,v=z.length;F<v;F++)O.push(new google.maps.LatLng(z[F].lat(),z[F].lng()));u.interval=u.interval||1E3;G(O,10)}})}else if(typeof u.tween==="object"){var n=C;a=0;for(var j=u.tween.length;a<j;a++){u.tween[a].interval=u.tween[a].interval||1E3;G(u.tween,10)}}}u.onmaploaded&&u.onmaploaded(u,r)}else setTimeout(function(){f()},13)};f()},end:function(){if(r)r.getDiv().style.display="none"},_teardown:function(o){var u=document.getElementById(o.target);u&&u.removeChild(k);
182
+ k=r=m=null;o._map=null}}},{about:{name:"Popcorn Google Map Plugin",version:"0.1",author:"@annasob",website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"start",label:"Start"},end:{elem:"input",type:"start",label:"End"},target:"map-container",type:{elem:"select",options:["ROADMAP","SATELLITE","STREETVIEW","HYBRID","TERRAIN","STAMEN-WATERCOLOR","STAMEN-TERRAIN","STAMEN-TONER"],label:"Map Type",optional:true},zoom:{elem:"input",type:"text",label:"Zoom","default":0,optional:true},lat:{elem:"input",
183
+ type:"text",label:"Lat",optional:true},lng:{elem:"input",type:"text",label:"Lng",optional:true},location:{elem:"input",type:"text",label:"Location","default":"Toronto, Ontario, Canada"},heading:{elem:"input",type:"text",label:"Heading","default":0,optional:true},pitch:{elem:"input",type:"text",label:"Pitch","default":1,optional:true}}})})(Popcorn);(function(p){p.plugin("mustache",function(e){var l,d,b,h;p.getScript("http://mustache.github.com/extras/mustache.js");var i=!!e.dynamic,g=typeof e.template,k=typeof e.data,r=document.getElementById(e.target);e.container=r||document.createElement("div");if(g==="function")if(i)b=e.template;else h=e.template(e);else h=g==="string"?e.template:"";if(k==="function")if(i)l=e.data;else d=e.data(e);else d=k==="string"?JSON.parse(e.data):k==="object"?e.data:"";return{start:function(m,t){var q=function(){if(window.Mustache){if(l)d=
184
+ l(t);if(b)h=b(t);var o=Mustache.to_html(h,d).replace(/^\s*/mg,"");t.container.innerHTML=o}else setTimeout(function(){q()},10)};q()},end:function(m,t){t.container.innerHTML=""},_teardown:function(){l=d=b=h=null}}},{about:{name:"Popcorn Mustache Plugin",version:"0.1",author:"David Humphrey (@humphd)",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"mustache-container",template:{elem:"input",type:"text",
185
+ label:"Template"},data:{elem:"input",type:"text",label:"Data"},dynamic:{elem:"input",type:"checkbox",label:"Dynamic","default":true}}})})(Popcorn);document.addEventListener("click",function(p){p=p.target;if(p.nodeName==="A"||p.parentNode&&p.parentNode.nodeName==="A")Popcorn.instances.forEach(function(e){e.options.pauseOnLinkClicked&&e.pause()})},false);(function(p){p.plugin("footnote",{manifest:{about:{name:"Popcorn Footnote Plugin",version:"0.2",author:"@annasob, @rwaldron",website:"annasob.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},text:{elem:"input",type:"text",label:"Text"},target:"footnote-container"}},_setup:function(e){var l=p.dom.find(e.target);e._container=document.createElement("div");e._container.style.display="none";e._container.innerHTML=e.text;l.appendChild(e._container)},
186
+ start:function(e,l){l._container.style.display="inline"},end:function(e,l){l._container.style.display="none"},_teardown:function(e){var l=p.dom.find(e.target);l&&l.removeChild(e._container)}})})(Popcorn);(function(p){var e=1,l=false;p.plugin("googlefeed",function(d){var b=function(){var k=false,r=0,m=document.getElementsByTagName("link"),t=m.length,q=document.head||document.getElementsByTagName("head")[0],o=document.createElement("link");if(window.GFdynamicFeedControl)l=true;else p.getScript("//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js",function(){l=true});for(;r<t;r++)if(m[r].href==="//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css")k=true;if(!k){o.type=
187
+ "text/css";o.rel="stylesheet";o.href="//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";q.insertBefore(o,q.firstChild)}};window.google?b():p.getScript("//www.google.com/jsapi",function(){google.load("feeds","1",{callback:function(){b()}})});var h=document.createElement("div"),i=document.getElementById(d.target),g=function(){if(l)d.feed=new GFdynamicFeedControl(d.url,h,{vertical:d.orientation.toLowerCase()==="vertical"?true:false,horizontal:d.orientation.toLowerCase()==="horizontal"?
188
+ true:false,title:d.title=d.title||"Blog"});else setTimeout(function(){g()},5)};if(!d.orientation||d.orientation.toLowerCase()!=="vertical"&&d.orientation.toLowerCase()!=="horizontal")d.orientation="vertical";h.style.display="none";h.id="_feed"+e;h.style.width="100%";h.style.height="100%";e++;i&&i.appendChild(h);g();d.toString=function(){return d.url||d._natives.manifest.options.url["default"]};return{start:function(){h.setAttribute("style","display:inline")},end:function(){h.setAttribute("style",
189
+ "display:none")},_teardown:function(k){document.getElementById(k.target)&&document.getElementById(k.target).removeChild(h);delete k.feed}}},{about:{name:"Popcorn Google Feed Plugin",version:"0.1",author:"David Seifried",website:"dseifried.wordpress.com"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},target:"feed-container",url:{elem:"input",type:"url",label:"Feed URL","default":"http://planet.mozilla.org/rss20.xml"},title:{elem:"input",type:"text",
190
+ label:"Title","default":"Planet Mozilla",optional:true},orientation:{elem:"select",options:["Vertical","Horizontal"],label:"Orientation","default":"Vertical",optional:true}}})})(Popcorn);(function(p){function e(b){return String(b).replace(/&(?!\w+;)|[<>"']/g,function(h){return d[h]||h})}function l(b,h){var i=b.container=document.createElement("div"),g=i.style,k=b.media,r=function(){var m=b.position();g.fontSize="18px";g.width=k.offsetWidth+"px";g.top=m.top+k.offsetHeight-i.offsetHeight-40+"px";g.left=m.left+"px";setTimeout(r,10)};i.id=h||"";g.position="absolute";g.color="white";g.textShadow="black 2px 2px 6px";g.fontWeight="bold";g.textAlign="center";r();b.media.parentNode.appendChild(i);
191
+ return i}var d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};p.plugin("text",{manifest:{about:{name:"Popcorn Text Plugin",version:"0.1",author:"@humphd"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},text:{elem:"input",type:"text",label:"Text","default":"Popcorn.js"},escape:{elem:"input",type:"checkbox",label:"Escape"},multiline:{elem:"input",type:"checkbox",label:"Multiline"}}},_setup:function(b){var h,i,g=b._container=document.createElement("div");
192
+ g.style.display="none";if(b.target)if(h=p.dom.find(b.target)){if(["VIDEO","AUDIO"].indexOf(h.nodeName)>-1)h=l(this,b.target+"-overlay")}else h=l(this,b.target);else h=this.container?this.container:l(this);b._target=h;i=b.escape?e(b.text):b.text;i=b.multiline?i.replace(/\r?\n/gm,"<br>"):i;g.innerHTML=i||"";h.appendChild(g);b.toString=function(){return b.text||b._natives.manifest.options.text["default"]}},start:function(b,h){h._container.style.display="inline"},end:function(b,h){h._container.style.display=
193
+ "none"},_teardown:function(b){var h=b._target;h&&h.removeChild(b._container)}})})(Popcorn);(function(p){p.plugin("code",function(e){var l=false,d=this,b=function(){var h=function(i){return function(g,k){var r=function(){l&&g.call(d,k);l&&i(r)};r()}};return window.webkitRequestAnimationFrame?h(window.webkitRequestAnimationFrame):window.mozRequestAnimationFrame?h(window.mozRequestAnimationFrame):h(function(i){window.setTimeout(i,16)})}();if(!e.onStart||typeof e.onStart!=="function")e.onStart=p.nop;if(e.onEnd&&typeof e.onEnd!=="function")e.onEnd=undefined;if(e.onFrame&&typeof e.onFrame!==
194
+ "function")e.onFrame=undefined;return{start:function(h,i){i.onStart.call(d,i);if(i.onFrame){l=true;b(i.onFrame,i)}},end:function(h,i){if(i.onFrame)l=false;i.onEnd&&i.onEnd.call(d,i)}}},{about:{name:"Popcorn Code Plugin",version:"0.1",author:"David Humphrey (@humphd)",website:"http://vocamus.net/dave"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},onStart:{elem:"input",type:"function",label:"onStart"},onFrame:{elem:"input",type:"function",label:"onFrame",
195
+ optional:true},onEnd:{elem:"input",type:"function",label:"onEnd"}}})})(Popcorn);(function(p){function e(b){function h(){var r=b.getBoundingClientRect(),m=g.getBoundingClientRect();if(m.left!==r.left)g.style.left=r.left+"px";if(m.top!==r.top)g.style.top=r.top+"px"}var i=-1,g=document.createElement("div"),k=getComputedStyle(b).zIndex;g.setAttribute("data-popcorn-helper-container",true);g.style.position="absolute";g.style.zIndex=isNaN(k)?l:k+1;document.body.appendChild(g);return{element:g,start:function(){i=setInterval(h,d)},stop:function(){clearInterval(i);i=-1},destroy:function(){document.body.removeChild(g);
196
+ i!==-1&&clearInterval(i)}}}var l=2E3,d=10;p.plugin("image",{manifest:{about:{name:"Popcorn image Plugin",version:"0.1",author:"Scott Downe",website:"http://scottdowne.wordpress.com/"},options:{start:{elem:"input",type:"number",label:"Start"},end:{elem:"input",type:"number",label:"End"},src:{elem:"input",type:"url",label:"Image URL","default":"http://mozillapopcorn.org/wp-content/themes/popcorn/images/for_developers.png"},href:{elem:"input",type:"url",label:"Link","default":"http://mozillapopcorn.org/wp-content/themes/popcorn/images/for_developers.png",
197
+ optional:true},target:"image-container",text:{elem:"input",type:"text",label:"Caption","default":"Popcorn.js",optional:true}}},_setup:function(b){var h=document.createElement("img"),i=document.getElementById(b.target);b.anchor=document.createElement("a");b.anchor.style.position="relative";b.anchor.style.textDecoration="none";b.anchor.style.display="none";if(i)if(["VIDEO","AUDIO"].indexOf(i.nodeName)>-1){b.trackedContainer=e(i);b.trackedContainer.element.appendChild(b.anchor)}else i&&i.appendChild(b.anchor);
198
+ h.addEventListener("load",function(){h.style.borderStyle="none";b.anchor.href=b.href||b.src||"#";b.anchor.target="_blank";var g,k;h.style.height=i.style.height;h.style.width=i.style.width;b.anchor.appendChild(h);if(b.text){g=h.height/12+"px";k=document.createElement("div");p.extend(k.style,{color:"black",fontSize:g,fontWeight:"bold",position:"relative",textAlign:"center",width:h.style.width||h.width+"px",zIndex:"10"});k.innerHTML=b.text||"";k.style.top=(h.style.height.replace("px","")||h.height)/
199
+ 2-k.offsetHeight/2+"px";b.anchor.insertBefore(k,h)}},false);h.src=b.src;b.toString=function(){var g=b.src||b._natives.manifest.options.src["default"],k=g.replace(/.*\//g,"");return k.length?k:g}},start:function(b,h){h.anchor.style.display="inline";h.trackedContainer&&h.trackedContainer.start()},end:function(b,h){h.anchor.style.display="none";h.trackedContainer&&h.trackedContainer.stop()},_teardown:function(b){if(b.trackedContainer)b.trackedContainer.destroy();else b.anchor.parentNode&&b.anchor.parentNode.removeChild(b.anchor)}})})(Popcorn);(function(p){p.parser("parseXML","XML",function(e){var l={title:"",remote:"",data:[]},d={},b=function(m){m=m.split(":");if(m.length===1)return parseFloat(m[0],10);else if(m.length===2)return parseFloat(m[0],10)+parseFloat(m[1]/12,10);else if(m.length===3)return parseInt(m[0]*60,10)+parseFloat(m[1],10)+parseFloat(m[2]/12,10);else if(m.length===4)return parseInt(m[0]*3600,10)+parseInt(m[1]*60,10)+parseFloat(m[2],10)+parseFloat(m[3]/12,10)},h=function(m){for(var t={},q=0,o=m.length;q<o;q++){var u=m.item(q).nodeName,
200
+ E=m.item(q).nodeValue,C=d[E];if(u==="in")t.start=b(E);else if(u==="out")t.end=b(E);else if(u==="resourceid")for(var f in C){if(C.hasOwnProperty(f))if(!t[f]&&f!=="id")t[f]=C[f]}else t[u]=E}return t},i=function(m,t){var q={};q[m]=t;return q},g=function(m,t,q){var o={};p.extend(o,t,h(m.attributes),{text:m.textContent||m.text});t=m.childNodes;if(t.length<1||t.length===1&&t[0].nodeType===3)if(q)d[o.id]=o;else l.data.push(i(m.nodeName,o));else for(m=0;m<t.length;m++)t[m].nodeType===1&&g(t[m],o,q)};e=e.documentElement.childNodes;
201
+ for(var k=0,r=e.length;k<r;k++)if(e[k].nodeType===1)e[k].nodeName==="manifest"?g(e[k],{},true):g(e[k],{},false);return l})})(Popcorn);(function(p){p.parser("parseSBV",function(e){var l={title:"",remote:"",data:[]},d=[],b=0,h=0,i=function(q){q=q.split(":");var o=q.length-1,u;try{u=parseInt(q[o-1],10)*60+parseFloat(q[o],10);if(o===2)u+=parseInt(q[0],10)*3600}catch(E){throw"Bad cue";}return u},g=function(q,o){var u={};u[q]=o;return u};e=e.text.split(/(?:\r\n|\r|\n)/gm);for(h=e.length;b<h;){var k={},r=[],m=e[b++].split(",");try{k.start=i(m[0]);for(k.end=i(m[1]);b<h&&e[b];)r.push(e[b++]);k.text=r.join("<br />");d.push(g("subtitle",k))}catch(t){for(;b<
202
+ h&&e[b];)b++}for(;b<h&&!e[b];)b++}l.data=d;return l})})(Popcorn);(function(p){p.parser("parseJSON","JSON",function(e){var l={title:"",remote:"",data:[]};p.forEach(e.data,function(d){l.data.push(d)});return l})})(Popcorn);(function(p){p.parser("parseTTXT",function(e){var l={title:"",remote:"",data:[]},d=function(k){k=k.split(":");var r=0;try{return parseFloat(k[0],10)*60*60+parseFloat(k[1],10)*60+parseFloat(k[2],10)}catch(m){r=0}return r},b=function(k,r){var m={};m[k]=r;return m};e=e.xml.lastChild.lastChild;for(var h=Number.MAX_VALUE,i=[];e;){if(e.nodeType===1&&e.nodeName==="TextSample"){var g={};g.start=d(e.getAttribute("sampleTime"));g.text=e.getAttribute("text");if(g.text){g.end=h-0.0010;i.push(b("subtitle",g))}h=
203
+ g.start}e=e.previousSibling}l.data=i.reverse();return l})})(Popcorn);(function(p){function e(g,k,r){var m=g.firstChild;g=l(g,r);r=[];for(var t;m;){if(m.nodeType===1)if(m.nodeName==="p")r.push(d(m,k,g));else if(m.nodeName==="div"){t=b(m.getAttribute("begin"));if(t<0)t=k;r.push.apply(r,e(m,t,g))}m=m.nextSibling}return r}function l(g,k){var r=g.getAttribute("region");return r!==null?r:k||""}function d(g,k,r){var m={};m.text=(g.textContent||g.text).replace(h,"").replace(i,"<br />");m.id=g.getAttribute("xml:id")||g.getAttribute("id");m.start=b(g.getAttribute("begin"),k);
204
+ m.end=b(g.getAttribute("end"),k);m.target=l(g,r);if(m.end<0){m.end=b(g.getAttribute("duration"),0);if(m.end>=0)m.end+=m.start;else m.end=Number.MAX_VALUE}return{subtitle:m}}function b(g,k){var r;if(!g)return-1;try{return p.util.toSeconds(g)}catch(m){for(var t=g.length-1;t>=0&&g[t]<="9"&&g[t]>="0";)t--;r=t;t=parseFloat(g.substring(0,r));r=g.substring(r);return t*({h:3600,m:60,s:1,ms:0.0010}[r]||-1)+(k||0)}}var h=/^[\s]+|[\s]+$/gm,i=/(?:\r\n|\r|\n)/gm;p.parser("parseTTML",function(g){var k={title:"",
205
+ remote:"",data:[]};if(!g.xml||!g.xml.documentElement)return k;g=g.xml.documentElement.firstChild;if(!g)return k;for(;g.nodeName!=="body";)g=g.nextSibling;if(g)k.data=e(g,0);return k})})(Popcorn);(function(p){function e(d){var b=d.split(":");d=d.length;var h;if(d!==12&&d!==9)throw"Bad cue";d=b.length-1;try{h=parseInt(b[d-1],10)*60+parseFloat(b[d],10);if(d===2)h+=parseInt(b[0],10)*3600}catch(i){throw"Bad cue";}return h}function l(d,b){var h={};h[d]=b;return h}p.parser("parseVTT",function(d){var b={title:"",remote:"",data:[]},h=[],i=0,g=0,k,r;d=d.text.split(/(?:\r\n|\r|\n)/gm);g=d.length;if(g===0||d[0]!=="WEBVTT")return b;for(i++;i<g;){k=[];try{for(var m=i;m<g&&!d[m];)m++;i=m;var t=d[i++];m=
206
+ void 0;var q={};if(!t||t.indexOf("--\>")===-1)throw"Bad cue";m=t.replace(/--\>/," --\> ").split(/[\t ]+/);if(m.length<2)throw"Bad cue";q.id=t;q.start=e(m[0]);q.end=e(m[2]);for(r=q;i<g&&d[i];)k.push(d[i++]);r.text=k.join("<br />");h.push(l("subtitle",r))}catch(o){for(i=i;i<g&&d[i];)i++;i=i}}b.data=h;return b})})(Popcorn);(function(p){function e(b,h){var i=b.substr(10).split(","),g;g={start:l(i[h.start]),end:l(i[h.end])};if(g.start===-1||g.end===-1)throw"Invalid time";var k=q.call(m,/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,""),r=k.replace,m;m=i.length;q=[];for(var t=h.text;t<m;t++)q.push(i[t]);m=q.join(",");var q=m.replace;g.text=r.call(k,/\\N/gi,"<br />");return g}function l(b){var h=b.split(":");if(b.length!==10||h.length<3)return-1;return parseInt(h[0],10)*3600+parseInt(h[1],10)*60+parseFloat(h[2],10)}function d(b,
207
+ h){var i={};i[b]=h;return i}p.parser("parseSSA",function(b){var h={title:"",remote:"",data:[]},i=[],g=0,k;b=b.text.split(/(?:\r\n|\r|\n)/gm);for(k=b.length;g<k&&b[g]!=="[Events]";)g++;var r=b[++g].substr(8).split(", "),m={},t,q;q=0;for(t=r.length;q<t;q++)if(r[q]==="Start")m.start=q;else if(r[q]==="End")m.end=q;else if(r[q]==="Text")m.text=q;for(;++g<k&&b[g]&&b[g][0]!=="[";)try{i.push(d("subtitle",e(b[g],m)))}catch(o){}h.data=i;return h})})(Popcorn);(function(p){function e(d,b){var h={};h[d]=b;return h}function l(d){d=d.split(":");try{var b=d[2].split(",");if(b.length===1)b=d[2].split(".");return parseFloat(d[0],10)*3600+parseFloat(d[1],10)*60+parseFloat(b[0],10)+parseFloat(b[1],10)/1E3}catch(h){return 0}}p.parser("parseSRT",function(d,b){var h={title:"",remote:"",data:[]},i=[],g=0,k=0,r,m,t,q,o;r=d.text.split(/(?:\r\n|\r|\n)/gm);for(t=r.length-1;t>=0&&!r[t];)t--;q=t+1;for(g=0;g<q;g++){o={};t=[];for(g=g;!r[g];)g++;g=g;o.id=parseInt(r[g++],10);
208
+ m=r[g++].split(/[\t ]*--\>[\t ]*/);o.start=l(m[0]);k=m[1].indexOf(" ");if(k!==-1)m[1]=m[1].substr(0,k);for(o.end=l(m[1]);g<q&&r[g];)t.push(r[g++]);o.text=t.join("\\N").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,"");o.text=o.text.replace(/</g,"&lt;").replace(/>/g,"&gt;");o.text=o.text.replace(/&lt;(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)(\/?)&gt;/gi,"<$1$3$7>");o.text=o.text.replace(/\\N/gi,"<br />");if(b&&b.target)o.target=b.target;i.push(e("subtitle",
209
+ o))}h.data=i;return h})})(Popcorn);(function(p,e){e.player("vimeo",{_canPlayType:function(l,d){return typeof d==="string"&&e.HTMLVimeoVideoElement._canPlaySrc(d)}});e.vimeo=function(l,d,b){typeof console!=="undefined"&&console.warn&&console.warn("Deprecated player 'vimeo'. Please use Popcorn.HTMLVimeoVideoElement directly.");var h=e.HTMLVimeoVideoElement(l);l=e(h,b);setTimeout(function(){h.src=d},0);return l}})(window,Popcorn);(function(p,e){var l=function(d,b){return typeof b==="string"&&e.HTMLYouTubeVideoElement._canPlaySrc(b)};e.player("youtube",{_canPlayType:l});e.youtube=function(d,b,h){typeof console!=="undefined"&&console.warn&&console.warn("Deprecated player 'youtube'. Please use Popcorn.HTMLYouTubeVideoElement directly.");var i=e.HTMLYouTubeVideoElement(d);d=e(i,h);setTimeout(function(){i.src=b},0);return d};e.youtube.canPlayType=l})(window,Popcorn);(function(p,e){e.player("soundcloud",{_canPlayType:function(l,d){return typeof d==="string"&&e.HTMLSoundCloudAudioElement._canPlaySrc(d)&&l.toLowerCase()!=="audio"}});e.soundcloud=function(l,d,b){typeof console!=="undefined"&&console.warn&&console.warn("Deprecated player 'soundcloud'. Please use Popcorn.HTMLSoundCloudAudioElement directly.");var h=e.HTMLSoundCloudAudioElement(l);l=e(h,b);setTimeout(function(){h.src=d},0);return l}})(window,Popcorn);
@@ -1,5 +1,5 @@
1
1
  /*
2
- * popcorn.js version 1.3
2
+ * popcorn.js version 1.5.6
3
3
  * http://popcornjs.org
4
4
  *
5
5
  * Copyright 2011, Mozilla Foundation
@@ -8,32 +8,172 @@
8
8
 
9
9
  (function() {
10
10
 
11
- document.addEventListener = document.addEventListener || function( event, callBack ) {
11
+ if ( !document.addEventListener && !document.removeEventListener && !document.dispatchEvent ) {
12
+ var events = {};
12
13
 
13
- event = ( event === "DOMContentLoaded" ) ? "onreadystatechange" : "on" + event;
14
+ var addEventListener = function( eventName, callBack ) {
14
15
 
15
- document.attachEvent( event, callBack );
16
+ eventName = ( eventName === "DOMContentLoaded" ) ? "readystatechange" : eventName;
17
+
18
+ if ( Event[ eventName.toUpperCase() ] || eventName === "readystatechange" ) {
19
+ document.attachEvent( "on" + eventName, callBack );
20
+ return;
21
+ }
22
+
23
+ if ( !events[ eventName ] ) {
24
+ events[ eventName ] = {
25
+ events: [],
26
+ queue: [],
27
+ active: false
28
+ };
29
+ }
30
+
31
+ if ( events[ eventName ].active ) {
32
+ events[ eventName ].queue.push( callBack );
33
+ } else {
34
+ events[ eventName ].events.push( callBack );
35
+ }
36
+ };
37
+
38
+ var removeEventListener = function( eventName, callBack ) {
39
+
40
+ eventName = ( eventName === "DOMContentLoaded" ) ? "readystatechange" : eventName;
41
+
42
+ var i = 0,
43
+ listeners = events[ eventName ];
44
+
45
+ if ( Event[ eventName.toUpperCase() ] || eventName === "readystatechange" ) {
46
+ document.detachEvent( "on" + eventName, callBack );
47
+ return;
48
+ }
49
+
50
+ if ( !listeners ) {
51
+ return;
52
+ }
53
+
54
+ for ( i = listeners.events.length - 1; i >= 0; i-- ) {
55
+ if ( callBack === listeners.events[ i ] ) {
56
+ delete listeners.events[ i ];
57
+ }
58
+ }
59
+
60
+ for ( i = listeners.queue.length - 1; i >= 0; i-- ) {
61
+ if ( callBack === listeners.queue[ i ] ) {
62
+ delete listeners.queue[ i ];
63
+ }
64
+ }
65
+ };
66
+
67
+ var dispatchEvent = function( eventObject ) {
68
+ var evt,
69
+ self = this,
70
+ eventInterface,
71
+ listeners,
72
+ eventName = eventObject.type,
73
+ queuedListener;
74
+
75
+ // A string was passed, create event object
76
+ if ( !eventName ) {
77
+
78
+ eventName = eventObject;
79
+ eventInterface = Popcorn.events.getInterface( eventName );
80
+
81
+ if ( eventInterface ) {
82
+
83
+ evt = document.createEvent( eventInterface );
84
+ evt.initCustomEvent( eventName, true, true, window, 1 );
85
+ }
86
+ }
87
+
88
+ listeners = events[ eventName ];
89
+
90
+ if ( listeners ) {
91
+ listeners.active = true;
92
+
93
+ for ( var i = 0; i < listeners.events.length; i++ ) {
94
+ if ( listeners.events[ i ] ) {
95
+ listeners.events[ i ].call( self, evt, self );
96
+ }
97
+ }
98
+
99
+ if ( listeners.queue.length ) {
100
+ while ( listeners.queue.length ) {
101
+ queuedListener = listeners.queue.shift();
102
+
103
+ if ( queuedListener ) {
104
+ listeners.events.push( queuedListener );
105
+ }
106
+ }
107
+ }
108
+
109
+ listeners.active = false;
110
+
111
+ listeners.events.forEach(function( listener ) {
112
+ if ( !listener ) {
113
+ listeners.events.splice( listeners.events.indexOf( listener ), 1 );
114
+ }
115
+ });
116
+
117
+ listeners.queue.forEach(function( listener ) {
118
+ if ( !listener ) {
119
+ listeners.queue.splice( listeners.queue.indexOf( listener ), 1 );
120
+ }
121
+ });
122
+ }
123
+ };
124
+
125
+ document.addEventListener = addEventListener;
126
+ document.removeEventListener = removeEventListener;
127
+ document.dispatchEvent = dispatchEvent;
128
+
129
+ }
130
+
131
+ if ( !Event.prototype.preventDefault ) {
132
+ Event.prototype.preventDefault = function() {
133
+ this.returnValue = false;
134
+ };
135
+ }
136
+ if ( !Event.prototype.stopPropagation ) {
137
+ Event.prototype.stopPropagation = function() {
138
+ this.cancelBubble = true;
139
+ };
140
+ }
141
+
142
+ window.addEventListener = window.addEventListener || function( event, callBack ) {
143
+
144
+ event = "on" + event;
145
+
146
+ window.attachEvent( event, callBack );
16
147
  };
17
148
 
18
- document.removeEventListener = document.removeEventListener || function( event, callBack ) {
149
+ window.removeEventListener = window.removeEventListener || function( event, callBack ) {
19
150
 
20
- event = ( event === "DOMContentLoaded" ) ? "onreadystatechange" : "on" + event;
151
+ event = "on" + event;
21
152
 
22
- document.detachEvent( event, callBack );
153
+ window.detachEvent( event, callBack );
23
154
  };
24
155
 
25
156
  HTMLScriptElement.prototype.addEventListener = HTMLScriptElement.prototype.addEventListener || function( event, callBack ) {
26
157
 
27
158
  event = ( event === "load" ) ? "onreadystatechange" : "on" + event;
28
159
 
29
- this.attachEvent( event, callBack );
160
+ if( event === "onreadystatechange" ){
161
+ callBack.readyStateCheck = callBack.readyStateCheck || function( e ){
162
+
163
+ if( self.readyState === "loaded" ){
164
+ callBack( e );
165
+ }
166
+ };
167
+ }
168
+
169
+ this.attachEvent( event, ( callBack.readyStateCheck || callBack ) );
30
170
  };
31
171
 
32
172
  HTMLScriptElement.prototype.removeEventListener = HTMLScriptElement.prototype.removeEventListener || function( event, callBack ) {
33
173
 
34
174
  event = ( event === "load" ) ? "onreadystatechange" : "on" + event;
35
175
 
36
- this.detachEvent( event, callBack );
176
+ this.detachEvent( event, ( callBack.readyStateCheck || callBack ) );
37
177
  };
38
178
 
39
179
  document.createEvent = document.createEvent || function ( type ) {
@@ -43,9 +183,14 @@
43
183
  target : null,
44
184
  currentTarget : null,
45
185
  cancelable : false,
186
+ detail: false,
46
187
  bubbles : false,
47
188
  initEvent : function (type, bubbles, cancelable) {
48
- this.type = type;
189
+ this.type = type;
190
+ },
191
+ initCustomEvent: function(type, bubbles, cancelable, detail) {
192
+ this.type = type;
193
+ this.detail = detail;
49
194
  },
50
195
  stopPropagation : function () {},
51
196
  stopImmediatePropagation : function () {}
@@ -197,6 +342,119 @@
197
342
  return -1;
198
343
  }
199
344
  }
345
+
346
+ if ( typeof String.prototype.trim !== "function" ) {
347
+
348
+ String.prototype.trim = function() {
349
+ return this.replace(/^\s+|\s+$/g, "");
350
+ };
351
+ }
352
+
353
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
354
+ if (!Object.keys) {
355
+ Object.keys = (function () {
356
+ 'use strict';
357
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
358
+ hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
359
+ dontEnums = [
360
+ 'toString',
361
+ 'toLocaleString',
362
+ 'valueOf',
363
+ 'hasOwnProperty',
364
+ 'isPrototypeOf',
365
+ 'propertyIsEnumerable',
366
+ 'constructor'
367
+ ],
368
+ dontEnumsLength = dontEnums.length;
369
+
370
+ return function (obj) {
371
+ if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
372
+ throw new TypeError('Object.keys called on non-object');
373
+ }
374
+
375
+ var result = [], prop, i;
376
+
377
+ for (prop in obj) {
378
+ if (hasOwnProperty.call(obj, prop)) {
379
+ result.push(prop);
380
+ }
381
+ }
382
+
383
+ if (hasDontEnumBug) {
384
+ for (i = 0; i < dontEnumsLength; i++) {
385
+ if (hasOwnProperty.call(obj, dontEnums[i])) {
386
+ result.push(dontEnums[i]);
387
+ }
388
+ }
389
+ }
390
+ return result;
391
+ };
392
+ }());
393
+ }
394
+
395
+ if ( !Object.defineProperties ) {
396
+ Object.defineProperties = function(obj, properties) {
397
+ function convertToDescriptor(desc) {
398
+ function hasProperty(obj, prop) {
399
+ return Object.prototype.hasOwnProperty.call(obj, prop);
400
+ }
401
+
402
+ function isCallable(v) {
403
+ // NB: modify as necessary if other values than functions are callable.
404
+ return typeof v === "function";
405
+ }
406
+
407
+ if (typeof desc !== "object" || desc === null)
408
+ throw new TypeError("bad desc");
409
+
410
+ var d = {};
411
+
412
+ if (hasProperty(desc, "enumerable"))
413
+ d.enumerable = !!obj.enumerable;
414
+ if (hasProperty(desc, "configurable"))
415
+ d.configurable = !!desc.configurable;
416
+ if (hasProperty(desc, "value"))
417
+ d.value = obj.value;
418
+ if (hasProperty(desc, "writable"))
419
+ d.writable = !!desc.writable;
420
+ if ( hasProperty(desc, "get") ) {
421
+ var g = desc.get;
422
+
423
+ if (!isCallable(g) && g !== "undefined")
424
+ throw new TypeError("bad get");
425
+ d.get = g;
426
+ }
427
+ if ( hasProperty(desc, "set") ) {
428
+ var s = desc.set;
429
+ if (!isCallable(s) && s !== "undefined")
430
+ throw new TypeError("bad set");
431
+ d.set = s;
432
+ }
433
+
434
+ if (("get" in d || "set" in d) && ("value" in d || "writable" in d))
435
+ throw new TypeError("identity-confused descriptor");
436
+
437
+ return d;
438
+ }
439
+
440
+ if (typeof obj !== "object" || obj === null)
441
+ throw new TypeError("bad obj");
442
+
443
+ properties = Object(properties);
444
+
445
+ var keys = Object.keys(properties);
446
+ var descs = [];
447
+
448
+ for (var i = 0; i < keys.length; i++)
449
+ descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);
450
+
451
+ for (var i = 0; i < descs.length; i++)
452
+ Object.defineProperty(obj, descs[i][0], descs[i][1]);
453
+
454
+ return obj;
455
+ };
456
+ }
457
+
200
458
  })();
201
459
  (function(global, document) {
202
460
 
@@ -270,6 +528,22 @@
270
528
  })( obj );
271
529
  },
272
530
 
531
+ Abstract = {
532
+ // [[Put]] props from dictionary onto |this|
533
+ // MUST BE CALLED FROM WITHIN A CONSTRUCTOR:
534
+ // Abstract.put.call( this, dictionary );
535
+ put: function( dictionary ) {
536
+ // For each own property of src, let key be the property key
537
+ // and desc be the property descriptor of the property.
538
+ for ( var key in dictionary ) {
539
+ if ( dictionary.hasOwnProperty( key ) ) {
540
+ this[ key ] = dictionary[ key ];
541
+ }
542
+ }
543
+ }
544
+ },
545
+
546
+
273
547
  // Declare constructor
274
548
  // Returns an instance object.
275
549
  Popcorn = function( entity, options ) {
@@ -278,7 +552,7 @@
278
552
  };
279
553
 
280
554
  // Popcorn API version, automatically inserted via build system.
281
- Popcorn.version = "1.3";
555
+ Popcorn.version = "1.5.6";
282
556
 
283
557
  // Boolean flag allowing a client to determine if Popcorn can be supported
284
558
  Popcorn.isSupported = true;
@@ -357,7 +631,7 @@
357
631
  // Create an audio or video element property reference
358
632
  this[ nodeName ] = this.media;
359
633
 
360
- this.options = options || {};
634
+ this.options = Popcorn.extend( {}, options ) || {};
361
635
 
362
636
  // Resolve custom ID or default prefixed ID
363
637
  this.id = this.options.id || Popcorn.guid( nodeName );
@@ -400,21 +674,7 @@
400
674
  trackRefs: {},
401
675
 
402
676
  // Playback track event queues
403
- trackEvents: {
404
- byStart: [{
405
-
406
- start: -1,
407
- end: -1
408
- }],
409
- byEnd: [{
410
- start: -1,
411
- end: -1
412
- }],
413
- animating: [],
414
- startIndex: 0,
415
- endIndex: 0,
416
- previousUpdateTime: -1
417
- }
677
+ trackEvents: new TrackEvents( this )
418
678
  };
419
679
 
420
680
  // Register new instance
@@ -433,7 +693,7 @@
433
693
  self.media.currentTime = 0;
434
694
  }
435
695
 
436
- self.media.removeEventListener( "loadeddata", isReady, false );
696
+ self.media.removeEventListener( "loadedmetadata", isReady, false );
437
697
 
438
698
  var duration, videoDurationPlus,
439
699
  runningPlugins, runningPlugin, rpLength, rpNatives;
@@ -450,6 +710,50 @@
450
710
  end: videoDurationPlus
451
711
  });
452
712
 
713
+ if ( !self.isDestroyed ) {
714
+ self.data.durationChange = function() {
715
+ var newDuration = self.media.duration,
716
+ newDurationPlus = newDuration + 1,
717
+ byStart = self.data.trackEvents.byStart,
718
+ byEnd = self.data.trackEvents.byEnd;
719
+
720
+ // Remove old padding events
721
+ byStart.pop();
722
+ byEnd.pop();
723
+
724
+ // Remove any internal tracking of events that have end times greater than duration
725
+ // otherwise their end events will never be hit.
726
+ for ( var k = byEnd.length - 1; k > 0; k-- ) {
727
+ if ( byEnd[ k ].end > newDuration ) {
728
+ self.removeTrackEvent( byEnd[ k ]._id );
729
+ }
730
+ }
731
+
732
+ // Remove any internal tracking of events that have end times greater than duration
733
+ // otherwise their end events will never be hit.
734
+ for ( var i = 0; i < byStart.length; i++ ) {
735
+ if ( byStart[ i ].end > newDuration ) {
736
+ self.removeTrackEvent( byStart[ i ]._id );
737
+ }
738
+ }
739
+
740
+ // References to byEnd/byStart are reset, so accessing it this way is
741
+ // forced upon us.
742
+ self.data.trackEvents.byEnd.push({
743
+ start: newDurationPlus,
744
+ end: newDurationPlus
745
+ });
746
+
747
+ self.data.trackEvents.byStart.push({
748
+ start: newDurationPlus,
749
+ end: newDurationPlus
750
+ });
751
+ };
752
+
753
+ // Listen for duration changes and adjust internal tracking of event timings
754
+ self.media.addEventListener( "durationchange", self.data.durationChange, false );
755
+ }
756
+
453
757
  if ( self.options.frameAnimation ) {
454
758
 
455
759
  // if Popcorn is created with frameAnimation option set to true,
@@ -498,19 +802,29 @@
498
802
  }
499
803
  };
500
804
 
501
- Object.defineProperty( this, "error", {
502
- get: function() {
503
-
504
- return self.media.error;
505
- }
506
- });
805
+ self.media.addEventListener( "error", function() {
806
+ self.error = self.media.error;
807
+ }, false );
507
808
 
508
- if ( self.media.readyState >= 2 ) {
809
+ // http://www.whatwg.org/specs/web-apps/current-work/#dom-media-readystate
810
+ //
811
+ // If media is in readyState (rS) >= 1, we know the media's duration,
812
+ // which is required before running the isReady function.
813
+ // If rS is 0, attach a listener for "loadedmetadata",
814
+ // ( Which indicates that the media has moved from rS 0 to 1 )
815
+ //
816
+ // This has been changed from a check for rS 2 because
817
+ // in certain conditions, Firefox can enter this code after dropping
818
+ // to rS 1 from a higher state such as 2 or 3. This caused a "loadeddata"
819
+ // listener to be attached to the media object, an event that had
820
+ // already triggered and would not trigger again. This left Popcorn with an
821
+ // instance that could never start a timeUpdate loop.
822
+ if ( self.media.readyState >= 1 ) {
509
823
 
510
824
  isReady();
511
825
  } else {
512
826
 
513
- self.media.addEventListener( "loadeddata", isReady, false );
827
+ self.media.addEventListener( "loadedmetadata", isReady, false );
514
828
  }
515
829
 
516
830
  return this;
@@ -612,6 +926,10 @@
612
926
 
613
927
  position: function( elem ) {
614
928
 
929
+ if ( !elem.parentNode ) {
930
+ return null;
931
+ }
932
+
615
933
  var clientRect = elem.getBoundingClientRect(),
616
934
  bounds = {},
617
935
  doc = elem.ownerDocument,
@@ -640,14 +958,26 @@
640
958
 
641
959
  disable: function( instance, plugin ) {
642
960
 
643
- if ( !instance.data.disabled[ plugin ] ) {
961
+ if ( instance.data.disabled[ plugin ] ) {
962
+ return;
963
+ }
964
+
965
+ instance.data.disabled[ plugin ] = true;
644
966
 
645
- instance.data.disabled[ plugin ] = true;
967
+ if ( plugin in Popcorn.registryByName &&
968
+ instance.data.running[ plugin ] ) {
646
969
 
647
970
  for ( var i = instance.data.running[ plugin ].length - 1, event; i >= 0; i-- ) {
648
971
 
649
972
  event = instance.data.running[ plugin ][ i ];
650
973
  event._natives.end.call( instance, null, event );
974
+
975
+ instance.emit( "trackend",
976
+ Popcorn.extend({}, event, {
977
+ plugin: event.type,
978
+ type: "trackend"
979
+ })
980
+ );
651
981
  }
652
982
  }
653
983
 
@@ -655,14 +985,27 @@
655
985
  },
656
986
  enable: function( instance, plugin ) {
657
987
 
658
- if ( instance.data.disabled[ plugin ] ) {
988
+ if ( !instance.data.disabled[ plugin ] ) {
989
+ return;
990
+ }
991
+
992
+ instance.data.disabled[ plugin ] = false;
659
993
 
660
- instance.data.disabled[ plugin ] = false;
994
+ if ( plugin in Popcorn.registryByName &&
995
+ instance.data.running[ plugin ] ) {
661
996
 
662
997
  for ( var i = instance.data.running[ plugin ].length - 1, event; i >= 0; i-- ) {
663
998
 
664
999
  event = instance.data.running[ plugin ][ i ];
665
1000
  event._natives.start.call( instance, null, event );
1001
+
1002
+ instance.emit( "trackstart",
1003
+ Popcorn.extend({}, event, {
1004
+ plugin: event.type,
1005
+ type: "trackstart",
1006
+ track: event
1007
+ })
1008
+ );
666
1009
  }
667
1010
  }
668
1011
 
@@ -695,6 +1038,8 @@
695
1038
  instance.data.timeUpdate && instance.media.removeEventListener( "timeupdate", instance.data.timeUpdate, false );
696
1039
  instance.isDestroyed = true;
697
1040
  }
1041
+
1042
+ Popcorn.instances.splice( Popcorn.instances.indexOf( instance ), 1 );
698
1043
  }
699
1044
  });
700
1045
 
@@ -776,7 +1121,8 @@
776
1121
  // Attach an event to a single point in time
777
1122
  exec: function( id, time, fn ) {
778
1123
  var length = arguments.length,
779
- trackEvent, sec;
1124
+ eventType = "trackadded",
1125
+ trackEvent, sec, options;
780
1126
 
781
1127
  // Check if first could possibly be a SMPTE string
782
1128
  // p.cue( "smpte string", fn );
@@ -811,11 +1157,19 @@
811
1157
 
812
1158
  } else {
813
1159
 
814
- // Get the trackEvent that matches the given id.
1160
+ // Get the TrackEvent that matches the given id.
815
1161
  trackEvent = this.getTrackEvent( id );
816
1162
 
817
1163
  if ( trackEvent ) {
818
1164
 
1165
+ // remove existing cue so a new one can be added via trackEvents.add
1166
+ this.data.trackEvents.remove( id );
1167
+ TrackEvent.end( this, trackEvent );
1168
+ // Update track event references
1169
+ Popcorn.removeTrackEvent.ref( this, id );
1170
+
1171
+ eventType = "cuechange";
1172
+
819
1173
  // p.cue( "my-id", 12 );
820
1174
  // p.cue( "my-id", function() { ... });
821
1175
  if ( typeof id === "string" && length === 2 ) {
@@ -823,7 +1177,7 @@
823
1177
  // p.cue( "my-id", 12 );
824
1178
  // The path will update the cue time.
825
1179
  if ( typeof time === "number" ) {
826
- // Re-use existing trackEvent start callback
1180
+ // Re-use existing TrackEvent start callback
827
1181
  fn = trackEvent._natives.start;
828
1182
  }
829
1183
 
@@ -831,7 +1185,7 @@
831
1185
  // The path will update the cue function
832
1186
  if ( typeof time === "function" ) {
833
1187
  fn = time;
834
- // Re-use existing trackEvent start time
1188
+ // Re-use existing TrackEvent start time
835
1189
  time = trackEvent.start;
836
1190
  }
837
1191
  }
@@ -849,8 +1203,9 @@
849
1203
  }
850
1204
 
851
1205
  // p.cue( "b", 11 );
1206
+ // p.cue( "b", 11, function() {} );
852
1207
  if ( typeof time === "number" ) {
853
- fn = Popcorn.nop();
1208
+ fn = fn || Popcorn.nop();
854
1209
  }
855
1210
 
856
1211
  // p.cue( "c", function() {});
@@ -863,9 +1218,7 @@
863
1218
  }
864
1219
  }
865
1220
 
866
- // Creating a one second track event with an empty end
867
- // Or update an existing track event with new values
868
- Popcorn.addTrackEvent( this, {
1221
+ options = {
869
1222
  id: id,
870
1223
  start: time,
871
1224
  end: time + 1,
@@ -875,7 +1228,42 @@
875
1228
  end: Popcorn.nop,
876
1229
  type: "cue"
877
1230
  }
878
- });
1231
+ };
1232
+
1233
+ if ( trackEvent ) {
1234
+ options = Popcorn.extend( trackEvent, options );
1235
+ }
1236
+
1237
+ if ( eventType === "cuechange" ) {
1238
+
1239
+ // Supports user defined track event id
1240
+ options._id = options.id || options._id || Popcorn.guid( options._natives.type );
1241
+
1242
+ this.data.trackEvents.add( options );
1243
+ TrackEvent.start( this, options );
1244
+
1245
+ this.timeUpdate( this, null, true );
1246
+
1247
+ // Store references to user added trackevents in ref table
1248
+ Popcorn.addTrackEvent.ref( this, options );
1249
+
1250
+ this.emit( eventType, Popcorn.extend({}, options, {
1251
+ id: id,
1252
+ type: eventType,
1253
+ previousValue: {
1254
+ time: trackEvent.start,
1255
+ fn: trackEvent._natives.start
1256
+ },
1257
+ currentValue: {
1258
+ time: time,
1259
+ fn: fn || Popcorn.nop
1260
+ },
1261
+ track: trackEvent
1262
+ }));
1263
+ } else {
1264
+ // Creating a one second track event with an empty end
1265
+ Popcorn.addTrackEvent( this, options );
1266
+ }
879
1267
 
880
1268
  return this;
881
1269
  },
@@ -1021,15 +1409,14 @@
1021
1409
  // Defines all Event handling static functions
1022
1410
  fn: {
1023
1411
  trigger: function( type, data ) {
1412
+ var eventInterface, evt, clonedEvents,
1413
+ events = this.data.events[ type ];
1024
1414
 
1025
- var eventInterface, evt;
1026
1415
  // setup checks for custom event system
1027
- if ( this.data.events[ type ] && Popcorn.sizeOf( this.data.events[ type ] ) ) {
1028
-
1416
+ if ( events ) {
1029
1417
  eventInterface = Popcorn.events.getInterface( type );
1030
1418
 
1031
1419
  if ( eventInterface ) {
1032
-
1033
1420
  evt = document.createEvent( eventInterface );
1034
1421
  evt.initEvent( type, true, true, global, 1 );
1035
1422
 
@@ -1038,33 +1425,38 @@
1038
1425
  return this;
1039
1426
  }
1040
1427
 
1041
- // Custom events
1042
- Popcorn.forEach( this.data.events[ type ], function( obj, key ) {
1043
-
1044
- obj.call( this, data );
1045
-
1046
- }, this );
1428
+ // clone events in case callbacks remove callbacks themselves
1429
+ clonedEvents = events.slice();
1047
1430
 
1431
+ // iterate through all callbacks
1432
+ while ( clonedEvents.length ) {
1433
+ clonedEvents.shift().call( this, data );
1434
+ }
1048
1435
  }
1049
1436
 
1050
1437
  return this;
1051
1438
  },
1052
1439
  listen: function( type, fn ) {
1053
-
1054
1440
  var self = this,
1055
1441
  hasEvents = true,
1056
1442
  eventHook = Popcorn.events.hooks[ type ],
1057
1443
  origType = type,
1444
+ clonedEvents,
1058
1445
  tmp;
1059
1446
 
1447
+ if ( typeof fn !== "function" ) {
1448
+ throw new Error( "Popcorn.js Error: Listener is not a function" );
1449
+ }
1450
+
1451
+ // Setup event registry entry
1060
1452
  if ( !this.data.events[ type ] ) {
1061
- this.data.events[ type ] = {};
1453
+ this.data.events[ type ] = [];
1454
+ // Toggle if the previous assumption was untrue
1062
1455
  hasEvents = false;
1063
1456
  }
1064
1457
 
1065
1458
  // Check and setup event hooks
1066
1459
  if ( eventHook ) {
1067
-
1068
1460
  // Execute hook add method if defined
1069
1461
  if ( eventHook.add ) {
1070
1462
  eventHook.add.call( this, {}, fn );
@@ -1089,39 +1481,61 @@
1089
1481
 
1090
1482
  // Setup event registry entry
1091
1483
  if ( !this.data.events[ type ] ) {
1092
- this.data.events[ type ] = {};
1484
+ this.data.events[ type ] = [];
1093
1485
  // Toggle if the previous assumption was untrue
1094
1486
  hasEvents = false;
1095
1487
  }
1096
1488
  }
1097
1489
 
1098
1490
  // Register event and handler
1099
- this.data.events[ type ][ fn.name || ( fn.toString() + Popcorn.guid() ) ] = fn;
1491
+ this.data.events[ type ].push( fn );
1100
1492
 
1101
1493
  // only attach one event of any type
1102
1494
  if ( !hasEvents && Popcorn.events.all.indexOf( type ) > -1 ) {
1103
-
1104
1495
  this.media.addEventListener( type, function( event ) {
1496
+ if ( self.data.events[ type ] ) {
1497
+ // clone events in case callbacks remove callbacks themselves
1498
+ clonedEvents = self.data.events[ type ].slice();
1105
1499
 
1106
- Popcorn.forEach( self.data.events[ type ], function( obj, key ) {
1107
- if ( typeof obj === "function" ) {
1108
- obj.call( self, event );
1500
+ // iterate through all callbacks
1501
+ while ( clonedEvents.length ) {
1502
+ clonedEvents.shift().call( self, event );
1109
1503
  }
1110
- });
1111
-
1112
- }, false);
1504
+ }
1505
+ }, false );
1113
1506
  }
1114
1507
  return this;
1115
1508
  },
1116
1509
  unlisten: function( type, fn ) {
1510
+ var ind,
1511
+ events = this.data.events[ type ];
1512
+
1513
+ if ( !events ) {
1514
+ return; // no listeners = nothing to do
1515
+ }
1117
1516
 
1118
- if ( this.data.events[ type ] && this.data.events[ type ][ fn ] ) {
1517
+ if ( typeof fn === "string" ) {
1518
+ // legacy support for string-based removal -- not recommended
1519
+ for ( var i = 0; i < events.length; i++ ) {
1520
+ if ( events[ i ].name === fn ) {
1521
+ // decrement i because array length just got smaller
1522
+ events.splice( i--, 1 );
1523
+ }
1524
+ }
1119
1525
 
1120
- delete this.data.events[ type ][ fn ];
1526
+ return this;
1527
+ } else if ( typeof fn === "function" ) {
1528
+ while( ind !== -1 ) {
1529
+ ind = events.indexOf( fn );
1530
+ if ( ind !== -1 ) {
1531
+ events.splice( ind, 1 );
1532
+ }
1533
+ }
1121
1534
 
1122
1535
  return this;
1123
1536
  }
1124
1537
 
1538
+ // if we got to this point, we are deleting all functions of this type
1125
1539
  this.data.events[ type ] = null;
1126
1540
 
1127
1541
  return this;
@@ -1136,7 +1550,10 @@
1136
1550
 
1137
1551
  if ( this.media.readyState ) {
1138
1552
 
1139
- callback.call( this, event );
1553
+ // always call canplayall asynchronously
1554
+ setTimeout(function() {
1555
+ callback.call( this, event );
1556
+ }.bind(this), 0 );
1140
1557
 
1141
1558
  state = true;
1142
1559
  }
@@ -1165,50 +1582,127 @@
1165
1582
  Popcorn.p[ key[ 0 ] ] = Popcorn.p[ key[ 1 ] ] = Popcorn.events.fn[ key[ 0 ] ];
1166
1583
  });
1167
1584
 
1168
- // Internal Only - Adds track events to the instance object
1169
- Popcorn.addTrackEvent = function( obj, track ) {
1170
- var trackEvent, isUpdate, eventType;
1585
+ // Internal Only - construct simple "TrackEvent"
1586
+ // data type objects
1587
+ function TrackEvent( track ) {
1588
+ Abstract.put.call( this, track );
1589
+ }
1171
1590
 
1172
- // Do a lookup for existing trackevents with this id
1173
- if ( track.id ) {
1174
- trackEvent = obj.getTrackEvent( track.id );
1175
- }
1591
+ // Determine if a TrackEvent's "start" and "trackstart" must be called.
1592
+ TrackEvent.start = function( instance, track ) {
1176
1593
 
1177
- // If a track event by this id currently exists, modify it
1178
- if ( trackEvent ) {
1179
- isUpdate = true;
1180
- // Create a new object with the existing trackEvent
1181
- // Extend with new track properties
1182
- track = Popcorn.extend( {}, trackEvent, track );
1594
+ if ( track.end > instance.media.currentTime &&
1595
+ track.start <= instance.media.currentTime && !track._running ) {
1183
1596
 
1184
- // Remove the existing track from the instance
1185
- obj.removeTrackEvent( track.id );
1186
- }
1597
+ track._running = true;
1598
+ instance.data.running[ track._natives.type ].push( track );
1187
1599
 
1188
- // Determine if this track has default options set for it
1189
- // If so, apply them to the track object
1190
- if ( track && track._natives && track._natives.type &&
1191
- ( obj.options.defaults && obj.options.defaults[ track._natives.type ] ) ) {
1600
+ if ( !instance.data.disabled[ track._natives.type ] ) {
1601
+
1602
+ track._natives.start.call( instance, null, track );
1192
1603
 
1193
- track = Popcorn.extend( {}, obj.options.defaults[ track._natives.type ], track );
1604
+ instance.emit( "trackstart",
1605
+ Popcorn.extend( {}, track, {
1606
+ plugin: track._natives.type,
1607
+ type: "trackstart",
1608
+ track: track
1609
+ })
1610
+ );
1611
+ }
1194
1612
  }
1613
+ };
1195
1614
 
1196
- if ( track._natives ) {
1197
- // Supports user defined track event id
1198
- track._id = track.id || track._id || Popcorn.guid( track._natives.type );
1615
+ // Determine if a TrackEvent's "end" and "trackend" must be called.
1616
+ TrackEvent.end = function( instance, track ) {
1617
+
1618
+ var runningPlugins;
1619
+
1620
+ if ( ( track.end <= instance.media.currentTime ||
1621
+ track.start > instance.media.currentTime ) && track._running ) {
1199
1622
 
1200
- // Push track event ids into the history
1201
- obj.data.history.push( track._id );
1623
+ runningPlugins = instance.data.running[ track._natives.type ];
1624
+
1625
+ track._running = false;
1626
+ runningPlugins.splice( runningPlugins.indexOf( track ), 1 );
1627
+
1628
+ if ( !instance.data.disabled[ track._natives.type ] ) {
1629
+
1630
+ track._natives.end.call( instance, null, track );
1631
+
1632
+ instance.emit( "trackend",
1633
+ Popcorn.extend( {}, track, {
1634
+ plugin: track._natives.type,
1635
+ type: "trackend",
1636
+ track: track
1637
+ })
1638
+ );
1639
+ }
1202
1640
  }
1641
+ };
1642
+
1643
+ // Internal Only - construct "TrackEvents"
1644
+ // data type objects that are used by the Popcorn
1645
+ // instance, stored at p.data.trackEvents
1646
+ function TrackEvents( parent ) {
1647
+ this.parent = parent;
1648
+
1649
+ this.byStart = [{
1650
+ start: -1,
1651
+ end: -1
1652
+ }];
1653
+
1654
+ this.byEnd = [{
1655
+ start: -1,
1656
+ end: -1
1657
+ }];
1658
+ this.animating = [];
1659
+ this.startIndex = 0;
1660
+ this.endIndex = 0;
1661
+ this.previousUpdateTime = -1;
1662
+
1663
+ this.count = 1;
1664
+ }
1665
+
1666
+ function isMatch( obj, key, value ) {
1667
+ return obj[ key ] && obj[ key ] === value;
1668
+ }
1669
+
1670
+ TrackEvents.prototype.where = function( params ) {
1671
+ return ( this.parent.getTrackEvents() || [] ).filter(function( event ) {
1672
+ var key, value;
1673
+
1674
+ // If no explicit params, match all TrackEvents
1675
+ if ( !params ) {
1676
+ return true;
1677
+ }
1678
+
1679
+ // Filter keys in params against both the top level properties
1680
+ // and the _natives properties
1681
+ for ( key in params ) {
1682
+ value = params[ key ];
1683
+ if ( isMatch( event, key, value ) || isMatch( event._natives, key, value ) ) {
1684
+ return true;
1685
+ }
1686
+ }
1687
+ return false;
1688
+ });
1689
+ };
1203
1690
 
1204
- track.start = Popcorn.util.toSeconds( track.start, obj.options.framerate );
1205
- track.end = Popcorn.util.toSeconds( track.end, obj.options.framerate );
1691
+ TrackEvents.prototype.add = function( track ) {
1206
1692
 
1207
1693
  // Store this definition in an array sorted by times
1208
- var byStart = obj.data.trackEvents.byStart,
1209
- byEnd = obj.data.trackEvents.byEnd,
1694
+ var byStart = this.byStart,
1695
+ byEnd = this.byEnd,
1210
1696
  startIndex, endIndex;
1211
1697
 
1698
+ // Push track event ids into the history
1699
+ if ( track && track._id ) {
1700
+ this.parent.data.history.push( track._id );
1701
+ }
1702
+
1703
+ track.start = Popcorn.util.toSeconds( track.start, this.parent.options.framerate );
1704
+ track.end = Popcorn.util.toSeconds( track.end, this.parent.options.framerate );
1705
+
1212
1706
  for ( startIndex = byStart.length - 1; startIndex >= 0; startIndex-- ) {
1213
1707
 
1214
1708
  if ( track.start >= byStart[ startIndex ].start ) {
@@ -1225,89 +1719,54 @@
1225
1719
  }
1226
1720
  }
1227
1721
 
1228
- // Display track event immediately if it's enabled and current
1229
- if ( track.end > obj.media.currentTime &&
1230
- track.start <= obj.media.currentTime ) {
1231
-
1232
- track._running = true;
1233
- obj.data.running[ track._natives.type ].push( track );
1234
-
1235
- if ( !obj.data.disabled[ track._natives.type ] ) {
1236
-
1237
- track._natives.start.call( obj, null, track );
1238
- }
1239
- }
1240
-
1241
1722
  // update startIndex and endIndex
1242
- if ( startIndex <= obj.data.trackEvents.startIndex &&
1243
- track.start <= obj.data.trackEvents.previousUpdateTime ) {
1723
+ if ( startIndex <= this.parent.data.trackEvents.startIndex &&
1724
+ track.start <= this.parent.data.trackEvents.previousUpdateTime ) {
1244
1725
 
1245
- obj.data.trackEvents.startIndex++;
1726
+ this.parent.data.trackEvents.startIndex++;
1246
1727
  }
1247
1728
 
1248
- if ( endIndex <= obj.data.trackEvents.endIndex &&
1249
- track.end < obj.data.trackEvents.previousUpdateTime ) {
1729
+ if ( endIndex <= this.parent.data.trackEvents.endIndex &&
1730
+ track.end < this.parent.data.trackEvents.previousUpdateTime ) {
1250
1731
 
1251
- obj.data.trackEvents.endIndex++;
1732
+ this.parent.data.trackEvents.endIndex++;
1252
1733
  }
1253
1734
 
1254
- this.timeUpdate( obj, null, true );
1255
-
1256
- // Store references to user added trackevents in ref table
1257
- if ( track._id ) {
1258
- Popcorn.addTrackEvent.ref( obj, track );
1259
- }
1735
+ this.count++;
1260
1736
 
1261
- // If the call to addTrackEvent was an update/modify call, fire an event
1262
- if ( isUpdate ) {
1737
+ };
1263
1738
 
1264
- // Determine appropriate event type to trigger
1265
- // they are identical in function, but the naming
1266
- // adds some level of intuition for the end developer
1267
- // to rely on
1268
- if ( track._natives.type === "cue" ) {
1269
- eventType = "cuechange";
1270
- } else {
1271
- eventType = "trackchange";
1272
- }
1739
+ TrackEvents.prototype.remove = function( removeId, state ) {
1273
1740
 
1274
- // Fire an event with change information
1275
- obj.emit( eventType, {
1276
- id: track.id,
1277
- previousValue: {
1278
- time: trackEvent.start,
1279
- fn: trackEvent._natives.start
1280
- },
1281
- currentValue: {
1282
- time: track.start,
1283
- fn: track._natives.start
1284
- }
1285
- });
1741
+ if ( removeId instanceof TrackEvent ) {
1742
+ removeId = removeId.id;
1286
1743
  }
1287
- };
1288
-
1289
- // Internal Only - Adds track event references to the instance object's trackRefs hash table
1290
- Popcorn.addTrackEvent.ref = function( obj, track ) {
1291
- obj.data.trackRefs[ track._id ] = track;
1292
1744
 
1293
- return obj;
1294
- };
1745
+ if ( typeof removeId === "object" ) {
1746
+ // Filter by key=val and remove all matching TrackEvents
1747
+ this.where( removeId ).forEach(function( event ) {
1748
+ // |this| refers to the calling Popcorn "parent" instance
1749
+ this.removeTrackEvent( event._id );
1750
+ }, this.parent );
1295
1751
 
1296
- Popcorn.removeTrackEvent = function( obj, removeId ) {
1752
+ return this;
1753
+ }
1297
1754
 
1298
- var start, end, animate,
1299
- historyLen = obj.data.history.length,
1300
- length = obj.data.trackEvents.byStart.length,
1755
+ var start, end, animate, historyLen, track,
1756
+ length = this.byStart.length,
1301
1757
  index = 0,
1302
1758
  indexWasAt = 0,
1303
1759
  byStart = [],
1304
1760
  byEnd = [],
1305
1761
  animating = [],
1306
- history = [];
1762
+ history = [],
1763
+ comparable = {};
1764
+
1765
+ state = state || {};
1307
1766
 
1308
1767
  while ( --length > -1 ) {
1309
- start = obj.data.trackEvents.byStart[ index ];
1310
- end = obj.data.trackEvents.byEnd[ index ];
1768
+ start = this.byStart[ index ];
1769
+ end = this.byEnd[ index ];
1311
1770
 
1312
1771
  // Padding events will not have _id properties.
1313
1772
  // These should be safely pushed onto the front and back of the
@@ -1334,11 +1793,8 @@
1334
1793
  if ( start._id === removeId ) {
1335
1794
  indexWasAt = index;
1336
1795
 
1337
- // If a _teardown function was defined,
1338
- // enforce for track event removals
1339
- if ( start._natives._teardown ) {
1340
- start._natives._teardown.call( obj, start );
1341
- }
1796
+ // cache the track event being removed
1797
+ track = start;
1342
1798
  }
1343
1799
  }
1344
1800
  // Increment the track index
@@ -1349,12 +1805,12 @@
1349
1805
  // if animating track events should also be filtered for removal.
1350
1806
  // Reset index below to be used by the reverse while as an
1351
1807
  // incrementing counter
1352
- length = obj.data.trackEvents.animating.length;
1808
+ length = this.animating.length;
1353
1809
  index = 0;
1354
1810
 
1355
1811
  if ( length ) {
1356
1812
  while ( --length > -1 ) {
1357
- animate = obj.data.trackEvents.animating[ index ];
1813
+ animate = this.animating[ index ];
1358
1814
 
1359
1815
  // Padding events will not have _id properties.
1360
1816
  // These should be safely pushed onto the front and back of the
@@ -1373,29 +1829,139 @@
1373
1829
  }
1374
1830
 
1375
1831
  // Update
1376
- if ( indexWasAt <= obj.data.trackEvents.startIndex ) {
1377
- obj.data.trackEvents.startIndex--;
1832
+ if ( indexWasAt <= this.startIndex ) {
1833
+ this.startIndex--;
1378
1834
  }
1379
1835
 
1380
- if ( indexWasAt <= obj.data.trackEvents.endIndex ) {
1381
- obj.data.trackEvents.endIndex--;
1836
+ if ( indexWasAt <= this.endIndex ) {
1837
+ this.endIndex--;
1382
1838
  }
1383
1839
 
1384
- obj.data.trackEvents.byStart = byStart;
1385
- obj.data.trackEvents.byEnd = byEnd;
1386
- obj.data.trackEvents.animating = animating;
1840
+ this.byStart = byStart;
1841
+ this.byEnd = byEnd;
1842
+ this.animating = animating;
1843
+ this.count--;
1844
+
1845
+ historyLen = this.parent.data.history.length;
1387
1846
 
1388
1847
  for ( var i = 0; i < historyLen; i++ ) {
1389
- if ( obj.data.history[ i ] !== removeId ) {
1390
- history.push( obj.data.history[ i ] );
1848
+ if ( this.parent.data.history[ i ] !== removeId ) {
1849
+ history.push( this.parent.data.history[ i ] );
1391
1850
  }
1392
1851
  }
1393
1852
 
1394
1853
  // Update ordered history array
1395
- obj.data.history = history;
1854
+ this.parent.data.history = history;
1396
1855
 
1397
- // Update track event references
1856
+ };
1857
+
1858
+ // Helper function used to retrieve old values of properties that
1859
+ // are provided for update.
1860
+ function getPreviousProperties( oldOptions, newOptions ) {
1861
+ var matchProps = {};
1862
+
1863
+ for ( var prop in oldOptions ) {
1864
+ if ( hasOwn.call( newOptions, prop ) && hasOwn.call( oldOptions, prop ) ) {
1865
+ matchProps[ prop ] = oldOptions[ prop ];
1866
+ }
1867
+ }
1868
+
1869
+ return matchProps;
1870
+ }
1871
+
1872
+ // Internal Only - Adds track events to the instance object
1873
+ Popcorn.addTrackEvent = function( obj, track ) {
1874
+ var temp;
1875
+
1876
+ if ( track instanceof TrackEvent ) {
1877
+ return;
1878
+ }
1879
+
1880
+ track = new TrackEvent( track );
1881
+
1882
+ // Determine if this track has default options set for it
1883
+ // If so, apply them to the track object
1884
+ if ( track && track._natives && track._natives.type &&
1885
+ ( obj.options.defaults && obj.options.defaults[ track._natives.type ] ) ) {
1886
+
1887
+ // To ensure that the TrackEvent Invariant Policy is enforced,
1888
+ // First, copy the properties of the newly created track event event
1889
+ // to a temporary holder
1890
+ temp = Popcorn.extend( {}, track );
1891
+
1892
+ // Next, copy the default onto the newly created trackevent, followed by the
1893
+ // temporary holder.
1894
+ Popcorn.extend( track, obj.options.defaults[ track._natives.type ], temp );
1895
+ }
1896
+
1897
+ if ( track._natives ) {
1898
+ // Supports user defined track event id
1899
+ track._id = track.id || track._id || Popcorn.guid( track._natives.type );
1900
+
1901
+ // Trigger _setup method if exists
1902
+ if ( track._natives._setup ) {
1903
+
1904
+ track._natives._setup.call( obj, track );
1905
+
1906
+ obj.emit( "tracksetup", Popcorn.extend( {}, track, {
1907
+ plugin: track._natives.type,
1908
+ type: "tracksetup",
1909
+ track: track
1910
+ }));
1911
+ }
1912
+ }
1913
+
1914
+ obj.data.trackEvents.add( track );
1915
+ TrackEvent.start( obj, track );
1916
+
1917
+ this.timeUpdate( obj, null, true );
1918
+
1919
+ // Store references to user added trackevents in ref table
1920
+ if ( track._id ) {
1921
+ Popcorn.addTrackEvent.ref( obj, track );
1922
+ }
1923
+
1924
+ obj.emit( "trackadded", Popcorn.extend({}, track,
1925
+ track._natives ? { plugin: track._natives.type } : {}, {
1926
+ type: "trackadded",
1927
+ track: track
1928
+ }));
1929
+ };
1930
+
1931
+ // Internal Only - Adds track event references to the instance object's trackRefs hash table
1932
+ Popcorn.addTrackEvent.ref = function( obj, track ) {
1933
+ obj.data.trackRefs[ track._id ] = track;
1934
+
1935
+ return obj;
1936
+ };
1937
+
1938
+ Popcorn.removeTrackEvent = function( obj, removeId ) {
1939
+ var track = obj.getTrackEvent( removeId );
1940
+
1941
+ if ( !track ) {
1942
+ return;
1943
+ }
1944
+
1945
+ // If a _teardown function was defined,
1946
+ // enforce for track event removals
1947
+ if ( track._natives._teardown ) {
1948
+ track._natives._teardown.call( obj, track );
1949
+ }
1950
+
1951
+ obj.data.trackEvents.remove( removeId );
1952
+
1953
+ // Update track event references
1398
1954
  Popcorn.removeTrackEvent.ref( obj, removeId );
1955
+
1956
+ if ( track._natives ) {
1957
+
1958
+ // Fire a trackremoved event
1959
+ obj.emit( "trackremoved", Popcorn.extend({}, track, {
1960
+ plugin: track._natives.type,
1961
+ type: "trackremoved",
1962
+ track: track
1963
+ }));
1964
+ }
1399
1965
  };
1400
1966
 
1401
1967
  // Internal Only - Removes track event references from instance object's trackRefs hash table
@@ -1445,7 +2011,6 @@
1445
2011
  };
1446
2012
 
1447
2013
  Popcorn.timeUpdate = function( obj, event ) {
1448
-
1449
2014
  var currentTime = obj.media.currentTime,
1450
2015
  previousTime = obj.data.trackEvents.previousUpdateTime,
1451
2016
  tracks = obj.data.trackEvents,
@@ -1486,7 +2051,8 @@
1486
2051
  obj.emit( trackend,
1487
2052
  Popcorn.extend({}, byEnd, {
1488
2053
  plugin: type,
1489
- type: trackend
2054
+ type: trackend,
2055
+ track: byEnd
1490
2056
  })
1491
2057
  );
1492
2058
  }
@@ -1505,12 +2071,10 @@
1505
2071
  byStart = tracks.byStart[ start ];
1506
2072
  natives = byStart._natives;
1507
2073
  type = natives && natives.type;
1508
-
1509
2074
  // If plugin does not exist on this instance, remove it
1510
2075
  if ( !natives ||
1511
2076
  ( !!registryByName[ type ] ||
1512
2077
  !!obj[ type ] ) ) {
1513
-
1514
2078
  if ( byStart.end > currentTime &&
1515
2079
  byStart._running === false ) {
1516
2080
 
@@ -1524,7 +2088,8 @@
1524
2088
  obj.emit( trackstart,
1525
2089
  Popcorn.extend({}, byStart, {
1526
2090
  plugin: type,
1527
- type: trackstart
2091
+ type: trackstart,
2092
+ track: byStart
1528
2093
  })
1529
2094
  );
1530
2095
  }
@@ -1564,7 +2129,8 @@
1564
2129
  obj.emit( trackend,
1565
2130
  Popcorn.extend({}, byStart, {
1566
2131
  plugin: type,
1567
- type: trackend
2132
+ type: trackend,
2133
+ track: byStart
1568
2134
  })
1569
2135
  );
1570
2136
  }
@@ -1601,7 +2167,8 @@
1601
2167
  obj.emit( trackstart,
1602
2168
  Popcorn.extend({}, byEnd, {
1603
2169
  plugin: type,
1604
- type: trackstart
2170
+ type: trackstart,
2171
+ track: byEnd
1605
2172
  })
1606
2173
  );
1607
2174
  }
@@ -1678,11 +2245,11 @@
1678
2245
 
1679
2246
  // Provides some sugar, but ultimately extends
1680
2247
  // the definition into Popcorn.p
1681
- var reserved = [ "start", "end" ],
2248
+ var isfn = typeof definition === "function",
2249
+ blacklist = [ "start", "end", "type", "manifest" ],
2250
+ methods = [ "_setup", "_teardown", "start", "end", "frame" ],
1682
2251
  plugin = {},
1683
- setup,
1684
- isfn = typeof definition === "function",
1685
- methods = [ "_setup", "_teardown", "start", "end", "frame" ];
2252
+ setup;
1686
2253
 
1687
2254
  // combines calls of two function calls into one
1688
2255
  var combineFn = function( first, second ) {
@@ -1740,7 +2307,7 @@
1740
2307
 
1741
2308
  Popcorn.extend( natives, setup );
1742
2309
 
1743
- options._natives.type = name;
2310
+ options._natives.type = options._natives.plugin = name;
1744
2311
  options._running = false;
1745
2312
 
1746
2313
  natives.start = natives.start || natives[ "in" ];
@@ -1766,12 +2333,37 @@
1766
2333
  args[ 1 ]._running &&
1767
2334
  runningPlugins.splice( runningPlugins.indexOf( options ), 1 ) &&
1768
2335
  natives.end.apply( this, args );
2336
+
2337
+ args[ 1 ]._running = false;
2338
+ this.emit( "trackend",
2339
+ Popcorn.extend( {}, options, {
2340
+ plugin: natives.type,
2341
+ type: "trackend",
2342
+ track: Popcorn.getTrackEvent( this, options.id || options._id )
2343
+ })
2344
+ );
1769
2345
  }, natives._teardown );
1770
2346
 
2347
+ // extend teardown to always trigger trackteardown after teardown
2348
+ natives._teardown = combineFn( natives._teardown, function() {
2349
+
2350
+ this.emit( "trackteardown", Popcorn.extend( {}, options, {
2351
+ plugin: name,
2352
+ type: "trackteardown",
2353
+ track: Popcorn.getTrackEvent( this, options.id || options._id )
2354
+ }));
2355
+ });
2356
+
1771
2357
  // default to an empty string if no effect exists
1772
2358
  // split string into an array of effects
1773
- options.compose = options.compose && options.compose.split( " " ) || [];
1774
- options.effect = options.effect && options.effect.split( " " ) || [];
2359
+ options.compose = options.compose || [];
2360
+ if ( typeof options.compose === "string" ) {
2361
+ options.compose = options.compose.split( " " );
2362
+ }
2363
+ options.effect = options.effect || [];
2364
+ if ( typeof options.effect === "string" ) {
2365
+ options.effect = options.effect.split( " " );
2366
+ }
1775
2367
 
1776
2368
  // join the two arrays together
1777
2369
  options.compose = options.compose.concat( options.effect );
@@ -1828,29 +2420,52 @@
1828
2420
  options.target = manifestOpts && "target" in manifestOpts && manifestOpts.target;
1829
2421
  }
1830
2422
 
1831
- if ( options._natives ) {
2423
+ if ( !options._id && options._natives ) {
1832
2424
  // ensure an initial id is there before setup is called
1833
2425
  options._id = Popcorn.guid( options._natives.type );
1834
2426
  }
1835
2427
 
1836
- // Trigger _setup method if exists
1837
- options._natives._setup && options._natives._setup.call( this, options );
1838
-
1839
- // Create new track event for this instance
1840
- Popcorn.addTrackEvent( this, options );
2428
+ if ( options instanceof TrackEvent ) {
1841
2429
 
1842
- // Future support for plugin event definitions
1843
- // for all of the native events
1844
- Popcorn.forEach( setup, function( callback, type ) {
2430
+ if ( options._natives ) {
2431
+ // Supports user defined track event id
2432
+ options._id = options.id || options._id || Popcorn.guid( options._natives.type );
1845
2433
 
1846
- if ( type !== "type" ) {
2434
+ // Trigger _setup method if exists
2435
+ if ( options._natives._setup ) {
1847
2436
 
1848
- if ( reserved.indexOf( type ) === -1 ) {
2437
+ options._natives._setup.call( this, options );
1849
2438
 
1850
- this.on( type, callback );
2439
+ this.emit( "tracksetup", Popcorn.extend( {}, options, {
2440
+ plugin: options._natives.type,
2441
+ type: "tracksetup",
2442
+ track: options
2443
+ }));
1851
2444
  }
1852
2445
  }
1853
2446
 
2447
+ this.data.trackEvents.add( options );
2448
+ TrackEvent.start( this, options );
2449
+
2450
+ this.timeUpdate( this, null, true );
2451
+
2452
+ // Store references to user added trackevents in ref table
2453
+ if ( options._id ) {
2454
+ Popcorn.addTrackEvent.ref( this, options );
2455
+ }
2456
+ } else {
2457
+ // Create new track event for this instance
2458
+ Popcorn.addTrackEvent( this, options );
2459
+ }
2460
+
2461
+ // Future support for plugin event definitions
2462
+ // for all of the native events
2463
+ Popcorn.forEach( setup, function( callback, type ) {
2464
+ // Don't attempt to create events for certain properties:
2465
+ // "start", "end", "type", "manifest". Fixes #1365
2466
+ if ( blacklist.indexOf( type ) === -1 ) {
2467
+ this.on( type, callback );
2468
+ }
1854
2469
  }, this );
1855
2470
 
1856
2471
  return this;
@@ -1860,7 +2475,7 @@
1860
2475
  // Assign new named definition
1861
2476
  Popcorn.p[ name ] = plugin[ name ] = function( id, options ) {
1862
2477
  var length = arguments.length,
1863
- trackEvent, defaults, mergedSetupOpts;
2478
+ trackEvent, defaults, mergedSetupOpts, previousOpts, newOpts;
1864
2479
 
1865
2480
  // Shift arguments based on use case
1866
2481
  //
@@ -1882,9 +2497,108 @@
1882
2497
  // If the track event does exist, merge the updated properties
1883
2498
  } else {
1884
2499
 
1885
- options = Popcorn.extend( {}, trackEvent, options );
2500
+ newOpts = options;
2501
+ previousOpts = getPreviousProperties( trackEvent, newOpts );
2502
+
2503
+ // Call the plugins defined update method if provided. Allows for
2504
+ // custom defined updating for a track event to be defined by the plugin author
2505
+ if ( trackEvent._natives._update ) {
2506
+
2507
+ this.data.trackEvents.remove( trackEvent );
2508
+
2509
+ // It's safe to say that the intent of Start/End will never change
2510
+ // Update them first before calling update
2511
+ if ( hasOwn.call( options, "start" ) ) {
2512
+ trackEvent.start = options.start;
2513
+ }
2514
+
2515
+ if ( hasOwn.call( options, "end" ) ) {
2516
+ trackEvent.end = options.end;
2517
+ }
2518
+
2519
+ TrackEvent.end( this, trackEvent );
2520
+
2521
+ if ( isfn ) {
2522
+ definition.call( this, trackEvent );
2523
+ }
2524
+
2525
+ trackEvent._natives._update.call( this, trackEvent, options );
2526
+
2527
+ this.data.trackEvents.add( trackEvent );
2528
+ TrackEvent.start( this, trackEvent );
2529
+ } else {
2530
+ // This branch is taken when there is no explicitly defined
2531
+ // _update method for a plugin. Which will occur either explicitly or
2532
+ // as a result of the plugin definition being a function that _returns_
2533
+ // a definition object.
2534
+ //
2535
+ // In either case, this path can ONLY be reached for TrackEvents that
2536
+ // already exist.
2537
+
2538
+ // Directly update the TrackEvent instance.
2539
+ // This supports TrackEvent invariant enforcement.
2540
+ Popcorn.extend( trackEvent, options );
2541
+
2542
+ this.data.trackEvents.remove( id );
2543
+
2544
+ // If a _teardown function was defined,
2545
+ // enforce for track event removals
2546
+ if ( trackEvent._natives._teardown ) {
2547
+ trackEvent._natives._teardown.call( this, trackEvent );
2548
+ }
2549
+
2550
+ // Update track event references
2551
+ Popcorn.removeTrackEvent.ref( this, id );
2552
+
2553
+ if ( isfn ) {
2554
+ pluginFn.call( this, definition.call( this, trackEvent ), trackEvent );
2555
+ } else {
1886
2556
 
1887
- Popcorn.addTrackEvent( this, options );
2557
+ // Supports user defined track event id
2558
+ trackEvent._id = trackEvent.id || trackEvent._id || Popcorn.guid( trackEvent._natives.type );
2559
+
2560
+ if ( trackEvent._natives && trackEvent._natives._setup ) {
2561
+
2562
+ trackEvent._natives._setup.call( this, trackEvent );
2563
+
2564
+ this.emit( "tracksetup", Popcorn.extend( {}, trackEvent, {
2565
+ plugin: trackEvent._natives.type,
2566
+ type: "tracksetup",
2567
+ track: trackEvent
2568
+ }));
2569
+ }
2570
+
2571
+ this.data.trackEvents.add( trackEvent );
2572
+ TrackEvent.start( this, trackEvent );
2573
+
2574
+ this.timeUpdate( this, null, true );
2575
+
2576
+ // Store references to user added trackevents in ref table
2577
+ Popcorn.addTrackEvent.ref( this, trackEvent );
2578
+ }
2579
+
2580
+ // Fire an event with change information
2581
+ this.emit( "trackchange", {
2582
+ id: trackEvent.id,
2583
+ type: "trackchange",
2584
+ previousValue: previousOpts,
2585
+ currentValue: trackEvent,
2586
+ track: trackEvent
2587
+ });
2588
+
2589
+ return this;
2590
+ }
2591
+
2592
+ if ( trackEvent._natives.type !== "cue" ) {
2593
+ // Fire an event with change information
2594
+ this.emit( "trackchange", {
2595
+ id: trackEvent.id,
2596
+ type: "trackchange",
2597
+ previousValue: previousOpts,
2598
+ currentValue: newOpts,
2599
+ track: trackEvent
2600
+ });
2601
+ }
1888
2602
 
1889
2603
  return this;
1890
2604
  }
@@ -1896,8 +2610,10 @@
1896
2610
  defaults = ( this.options.defaults && this.options.defaults[ name ] ) || {};
1897
2611
  mergedSetupOpts = Popcorn.extend( {}, defaults, options );
1898
2612
 
1899
- return pluginFn.call( this, isfn ? definition.call( this, mergedSetupOpts ) : definition,
2613
+ pluginFn.call( this, isfn ? definition.call( this, mergedSetupOpts ) : definition,
1900
2614
  mergedSetupOpts );
2615
+
2616
+ return this;
1901
2617
  };
1902
2618
 
1903
2619
  // if the manifest parameter exists we should extend it onto the definition object
@@ -2081,13 +2797,11 @@
2081
2797
  find: function( selector, context ) {
2082
2798
  var node = null;
2083
2799
 
2084
- // Trim leading/trailing whitespace to avoid false negatives
2085
- selector = selector.trim();
2086
-
2087
2800
  // Default context is the `document`
2088
2801
  context = context || document;
2089
2802
 
2090
2803
  if ( selector ) {
2804
+
2091
2805
  // If the selector does not begin with "#", "." or "[",
2092
2806
  // it could be either a nodeName or ID w/o "#"
2093
2807
  if ( !rnaiveExpr.test( selector ) ) {
@@ -2118,18 +2832,18 @@
2118
2832
  var rparams = /\?/,
2119
2833
  // XHR Setup object
2120
2834
  setup = {
2835
+ ajax: null,
2121
2836
  url: "",
2122
2837
  data: "",
2123
2838
  dataType: "",
2124
2839
  success: Popcorn.nop,
2125
2840
  type: "GET",
2126
2841
  async: true,
2127
- xhr: function() {
2128
- return new global.XMLHttpRequest();
2129
- }
2842
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8"
2130
2843
  };
2131
2844
 
2132
2845
  Popcorn.xhr = function( options ) {
2846
+ var settings;
2133
2847
 
2134
2848
  options.dataType = options.dataType && options.dataType.toLowerCase() || null;
2135
2849
 
@@ -2144,10 +2858,12 @@
2144
2858
  return;
2145
2859
  }
2146
2860
 
2147
- var settings = Popcorn.extend( {}, setup, options );
2861
+ // Merge the "setup" defaults and custom "options"
2862
+ // into a new plain object.
2863
+ settings = Popcorn.extend( {}, setup, options );
2148
2864
 
2149
2865
  // Create new XMLHttpRequest object
2150
- settings.ajax = settings.xhr();
2866
+ settings.ajax = new XMLHttpRequest();
2151
2867
 
2152
2868
  if ( settings.ajax ) {
2153
2869
 
@@ -2160,8 +2876,16 @@
2160
2876
  settings.data = null;
2161
2877
  }
2162
2878
 
2163
-
2879
+ // Open the request
2164
2880
  settings.ajax.open( settings.type, settings.url, settings.async );
2881
+
2882
+ // For POST, set the content-type request header
2883
+ if ( settings.type === "POST" ) {
2884
+ settings.ajax.setRequestHeader(
2885
+ "Content-Type", settings.contentType
2886
+ );
2887
+ }
2888
+
2165
2889
  settings.ajax.send( settings.data || null );
2166
2890
 
2167
2891
  return Popcorn.xhr.httpData( settings );
@@ -2297,8 +3021,20 @@
2297
3021
  head.removeChild( script );
2298
3022
  }, false );
2299
3023
 
2300
- script.src = url;
3024
+ script.addEventListener( "error", function( e ) {
3025
+ // Handling remote script loading callbacks
3026
+ success && success( { error: e } );
2301
3027
 
3028
+ // Executing for JSONP requests
3029
+ if ( !isScript ) {
3030
+ // Garbage collect the callback
3031
+ delete window[ callback ];
3032
+ }
3033
+ // Garbage collect the script resource
3034
+ head.removeChild( script );
3035
+ }, false );
3036
+
3037
+ script.src = url;
2302
3038
  head.insertBefore( script, head.firstChild );
2303
3039
 
2304
3040
  return;
@@ -2428,13 +3164,6 @@
2428
3164
  // ID string matching
2429
3165
  var rIdExp = /^(#([\w\-\_\.]+))$/;
2430
3166
 
2431
- var audioExtensions = "ogg|oga|aac|mp3|wav",
2432
- videoExtensions = "ogg|ogv|mp4|webm",
2433
- mediaExtensions = audioExtensions + "|" + videoExtensions;
2434
-
2435
- var audioExtensionRegexp = new RegExp( "^.*\\.(" + audioExtensions + ")($|\\?)" ),
2436
- mediaExtensionRegexp = new RegExp( "^.*\\.(" + mediaExtensions + ")($|\\?)" );
2437
-
2438
3167
  Popcorn.player = function( name, player ) {
2439
3168
 
2440
3169
  // return early if a player already exists under this name
@@ -2760,491 +3489,128 @@
2760
3489
  };
2761
3490
  };
2762
3491
 
2763
- // smart will attempt to find you a match, if it does not find a match,
2764
- // it will attempt to create a video element with the source,
2765
- // if that failed, it will throw.
3492
+ // Popcorn.smart will attempt to find you a wrapper or player. If it can't do that,
3493
+ // it will default to using an HTML5 video in the target.
2766
3494
  Popcorn.smart = function( target, src, options ) {
2767
- var playerType,
2768
- elementTypes = [ "AUDIO", "VIDEO" ],
2769
- sourceNode,
2770
- firstSrc,
2771
- node = Popcorn.dom.find( target ),
2772
- i, srcResult,
2773
- canPlayTypeTester = document.createElement( "video" ),
2774
- canPlayTypes = {
2775
- "ogg": "video/ogg",
2776
- "ogv": "video/ogg",
2777
- "oga": "audio/ogg",
2778
- "webm": "video/webm",
2779
- "mp4": "video/mp4",
2780
- "mp3": "audio/mp3"
2781
- };
2782
-
2783
- var canPlayType = function( type ) {
2784
-
2785
- return canPlayTypeTester.canPlayType( canPlayTypes[ type ] );
2786
- };
2787
-
2788
- var canPlaySrc = function( src ) {
2789
-
2790
- srcResult = mediaExtensionRegexp.exec( src );
2791
-
2792
- if ( !srcResult || !srcResult[ 1 ] ) {
2793
- return false;
2794
- }
2795
-
2796
- return canPlayType( srcResult[ 1 ] );
2797
- };
3495
+ var node = typeof target === "string" ? Popcorn.dom.find( target ) : target,
3496
+ i, srci, j, media, mediaWrapper, popcorn, srcLength,
3497
+ // We leave HTMLVideoElement and HTMLAudioElement wrappers out
3498
+ // of the mix, since we'll default to HTML5 video if nothing
3499
+ // else works. Waiting on #1254 before we add YouTube to this.
3500
+ wrappers = "HTMLYouTubeVideoElement HTMLVimeoVideoElement HTMLSoundCloudAudioElement HTMLNullVideoElement".split(" ");
2798
3501
 
2799
3502
  if ( !node ) {
2800
-
2801
- Popcorn.error( "Specified target " + target + " was not found." );
3503
+ Popcorn.error( "Specified target `" + target + "` was not found." );
2802
3504
  return;
2803
3505
  }
2804
3506
 
2805
- // For when no src is defined.
2806
- // Usually this is a video element with a src already on it.
2807
- if ( elementTypes.indexOf( node.nodeName ) > -1 && !src ) {
3507
+ // If our src is not an array, create an array of one.
3508
+ src = typeof src === "string" ? [ src ] : src;
2808
3509
 
2809
- if ( typeof src === "object" ) {
2810
-
2811
- options = src;
2812
- src = undefined;
2813
- }
2814
-
2815
- return Popcorn( node, options );
2816
- }
2817
-
2818
- // if our src is not an array, create an array of one.
2819
- if ( typeof( src ) === "string" ) {
2820
-
2821
- src = [ src ];
2822
- }
2823
-
2824
- // go through each src, and find the first playable.
2825
- // this only covers player sources popcorn knows of,
2826
- // and not things like a youtube src that is private.
2827
- // it will still consider a private youtube video to be playable.
3510
+ // Loop through each src, and find the first playable.
2828
3511
  for ( i = 0, srcLength = src.length; i < srcLength; i++ ) {
2829
-
2830
- // src is a playable HTML5 video, we don't need to check custom players.
2831
- if ( canPlaySrc( src[ i ] ) ) {
2832
-
2833
- src = src[ i ];
2834
- break;
3512
+ srci = src[ i ];
3513
+
3514
+ // See if we can use a wrapper directly, if not, try players.
3515
+ for ( j = 0; j < wrappers.length; j++ ) {
3516
+ mediaWrapper = Popcorn[ wrappers[ j ] ];
3517
+ if ( mediaWrapper && mediaWrapper._canPlaySrc( srci ) === "probably" ) {
3518
+ media = mediaWrapper( node );
3519
+ popcorn = Popcorn( media, options );
3520
+ // Set src, but not until after we return the media so the caller
3521
+ // can get error events, if any.
3522
+ setTimeout( function() {
3523
+ media.src = srci;
3524
+ }, 0 );
3525
+ return popcorn;
3526
+ }
2835
3527
  }
2836
3528
 
2837
- // for now we loop through and use the first valid player we find.
3529
+ // No wrapper can play this, check players.
2838
3530
  for ( var key in Popcorn.player.registry ) {
2839
-
2840
3531
  if ( Popcorn.player.registry.hasOwnProperty( key ) ) {
2841
-
2842
- if ( Popcorn.player.registry[ key ].canPlayType( node.nodeName, src[ i ] ) ) {
2843
-
3532
+ if ( Popcorn.player.registry[ key ].canPlayType( node.nodeName, srci ) ) {
2844
3533
  // Popcorn.smart( player, src, /* options */ )
2845
- return Popcorn[ key ]( node, src[ i ], options );
3534
+ return Popcorn[ key ]( node, srci, options );
2846
3535
  }
2847
3536
  }
2848
3537
  }
2849
3538
  }
2850
3539
 
2851
- // Popcorn.smart( div, src, /* options */ )
2852
- // attempting to create a video in a container
2853
- if ( elementTypes.indexOf( node.nodeName ) === -1 ) {
2854
-
2855
- firstSrc = typeof( src ) === "string" ? src : src.length ? src[ 0 ] : src;
2856
-
2857
- target = document.createElement( !!audioExtensionRegexp.exec( firstSrc ) ? elementTypes[ 0 ] : elementTypes[ 1 ] );
2858
-
2859
- // Controls are defaulted to being present
2860
- target.controls = true;
2861
-
2862
- node.appendChild( target );
2863
- node = target;
3540
+ // If we don't have any players or wrappers that can handle this,
3541
+ // Default to using HTML5 video. Similar to the HTMLVideoElement
3542
+ // wrapper, we put a video in the div passed to us via:
3543
+ // Popcorn.smart( div, src, options )
3544
+ var videoHTML,
3545
+ videoElement,
3546
+ videoID = Popcorn.guid( "popcorn-video-" ),
3547
+ videoHTMLContainer = document.createElement( "div" );
3548
+
3549
+ videoHTMLContainer.style.width = "100%";
3550
+ videoHTMLContainer.style.height = "100%";
3551
+
3552
+ // If we only have one source, do not bother with source elements.
3553
+ // This means we don't have the IE9 hack,
3554
+ // and we can properly listen to error events.
3555
+ // That way an error event can be told to backup to Flash if it fails.
3556
+ if ( src.length === 1 ) {
3557
+ videoElement = document.createElement( "video" );
3558
+ videoElement.id = videoID;
3559
+ node.appendChild( videoElement );
3560
+ setTimeout( function() {
3561
+ // Hack to decode html characters like &amp; to &
3562
+ var decodeDiv = document.createElement( "div" );
3563
+ decodeDiv.innerHTML = src[ 0 ];
3564
+
3565
+ videoElement.src = decodeDiv.firstChild.nodeValue;
3566
+ }, 0 );
3567
+ return Popcorn( '#' + videoID, options );
2864
3568
  }
2865
3569
 
2866
- options && options.events && options.events.error && node.addEventListener( "error", options.events.error, false );
2867
- node.src = src;
2868
-
2869
- return Popcorn( node, options );
3570
+ node.appendChild( videoHTMLContainer );
3571
+ // IE9 doesn't like dynamic creation of source elements on <video>
3572
+ // so we do it in one shot via innerHTML.
3573
+ videoHTML = '<video id="' + videoID + '" preload=auto autobuffer>';
3574
+ for ( i = 0, srcLength = src.length; i < srcLength; i++ ) {
3575
+ videoHTML += '<source src="' + src[ i ] + '">';
3576
+ }
3577
+ videoHTML += "</video>";
3578
+ videoHTMLContainer.innerHTML = videoHTML;
2870
3579
 
3580
+ if ( options && options.events && options.events.error ) {
3581
+ node.addEventListener( "error", options.events.error, false );
3582
+ }
3583
+ return Popcorn( '#' + videoID, options );
2871
3584
  };
2872
3585
  })( Popcorn );
2873
3586
  (function( window, Popcorn ) {
2874
- // A global callback for youtube... that makes me angry
2875
- window.onYouTubePlayerAPIReady = function() {
2876
3587
 
2877
- onYouTubePlayerAPIReady.ready = true;
2878
- for ( var i = 0; i < onYouTubePlayerAPIReady.waiting.length; i++ ) {
2879
- onYouTubePlayerAPIReady.waiting[ i ]();
2880
- }
3588
+ var canPlayType = function( nodeName, url ) {
3589
+ return ( typeof url === "string" &&
3590
+ Popcorn.HTMLYouTubeVideoElement._canPlaySrc( url ) );
2881
3591
  };
2882
3592
 
2883
- // existing youtube references can break us.
2884
- // remove it and use the one we can trust.
2885
- if ( window.YT ) {
2886
- window.quarantineYT = window.YT;
2887
- window.YT = null;
2888
- }
2889
-
2890
- onYouTubePlayerAPIReady.waiting = [];
2891
-
2892
- var _loading = false;
2893
-
2894
3593
  Popcorn.player( "youtube", {
2895
- _canPlayType: function( nodeName, url ) {
2896
-
2897
- return typeof url === "string" && (/(?:http:\/\/www\.|http:\/\/|www\.|\.|^)(youtu)/).test( url ) && nodeName.toLowerCase() !== "video";
2898
- },
2899
- _setup: function( options ) {
2900
- if ( !window.YT && !_loading ) {
2901
- _loading = true;
2902
- Popcorn.getScript( "//youtube.com/player_api" );
2903
- }
2904
-
2905
- var media = this,
2906
- autoPlay = false,
2907
- container = document.createElement( "div" ),
2908
- currentTime = 0,
2909
- paused = true,
2910
- seekTime = 0,
2911
- firstGo = true,
2912
- seeking = false,
2913
- fragmentStart = 0,
2914
-
2915
- // state code for volume changed polling
2916
- lastMuted = false,
2917
- lastVolume = 100,
2918
- playerQueue = Popcorn.player.playerQueue();
2919
-
2920
- var createProperties = function() {
2921
-
2922
- Popcorn.player.defineProperty( media, "currentTime", {
2923
- set: function( val ) {
2924
-
2925
- if ( options.destroyed ) {
2926
- return;
2927
- }
2928
-
2929
- seeking = true;
2930
- // make sure val is a number
2931
- currentTime = Math.round( +val * 100 ) / 100;
2932
- },
2933
- get: function() {
2934
-
2935
- return currentTime;
2936
- }
2937
- });
2938
-
2939
- Popcorn.player.defineProperty( media, "paused", {
2940
- get: function() {
2941
-
2942
- return paused;
2943
- }
2944
- });
2945
-
2946
- Popcorn.player.defineProperty( media, "muted", {
2947
- set: function( val ) {
2948
-
2949
- if ( options.destroyed ) {
2950
-
2951
- return val;
2952
- }
2953
-
2954
- if ( options.youtubeObject.isMuted() !== val ) {
2955
-
2956
- if ( val ) {
2957
-
2958
- options.youtubeObject.mute();
2959
- } else {
2960
-
2961
- options.youtubeObject.unMute();
2962
- }
2963
-
2964
- lastMuted = options.youtubeObject.isMuted();
2965
- media.dispatchEvent( "volumechange" );
2966
- }
2967
-
2968
- return options.youtubeObject.isMuted();
2969
- },
2970
- get: function() {
2971
-
2972
- if ( options.destroyed ) {
2973
-
2974
- return 0;
2975
- }
2976
-
2977
- return options.youtubeObject.isMuted();
2978
- }
2979
- });
2980
-
2981
- Popcorn.player.defineProperty( media, "volume", {
2982
- set: function( val ) {
2983
-
2984
- if ( options.destroyed ) {
2985
-
2986
- return val;
2987
- }
2988
-
2989
- if ( options.youtubeObject.getVolume() / 100 !== val ) {
2990
-
2991
- options.youtubeObject.setVolume( val * 100 );
2992
- lastVolume = options.youtubeObject.getVolume();
2993
- media.dispatchEvent( "volumechange" );
2994
- }
2995
-
2996
- return options.youtubeObject.getVolume() / 100;
2997
- },
2998
- get: function() {
2999
-
3000
- if ( options.destroyed ) {
3001
-
3002
- return 0;
3003
- }
3004
-
3005
- return options.youtubeObject.getVolume() / 100;
3006
- }
3007
- });
3008
-
3009
- media.play = function() {
3010
-
3011
- if ( options.destroyed ) {
3012
-
3013
- return;
3014
- }
3015
-
3016
- paused = false;
3017
- playerQueue.add(function() {
3018
-
3019
- if ( options.youtubeObject.getPlayerState() !== 1 ) {
3020
-
3021
- seeking = false;
3022
- options.youtubeObject.playVideo();
3023
- } else {
3024
- playerQueue.next();
3025
- }
3026
- });
3027
- };
3028
-
3029
- media.pause = function() {
3030
-
3031
- if ( options.destroyed ) {
3032
-
3033
- return;
3034
- }
3035
-
3036
- paused = true;
3037
- playerQueue.add(function() {
3038
-
3039
- if ( options.youtubeObject.getPlayerState() !== 2 ) {
3040
-
3041
- options.youtubeObject.pauseVideo();
3042
- } else {
3043
- playerQueue.next();
3044
- }
3045
- });
3046
- };
3047
- };
3048
-
3049
- container.id = media.id + Popcorn.guid();
3050
- options._container = container;
3051
- media.appendChild( container );
3052
-
3053
- var youtubeInit = function() {
3054
-
3055
- var src, query, params, playerVars, queryStringItem, firstPlay = true;
3056
-
3057
- var timeUpdate = function() {
3058
-
3059
- if ( options.destroyed ) {
3060
- return;
3061
- }
3062
-
3063
- if ( !seeking ) {
3064
- currentTime = options.youtubeObject.getCurrentTime();
3065
- media.dispatchEvent( "timeupdate" );
3066
- } else if ( currentTime === options.youtubeObject.getCurrentTime() ) {
3067
-
3068
- seeking = false;
3069
- media.dispatchEvent( "seeked" );
3070
- media.dispatchEvent( "timeupdate" );
3071
- } else {
3072
-
3073
- // keep trying the seek until it is right.
3074
- options.youtubeObject.seekTo( currentTime );
3075
- }
3076
- setTimeout( timeUpdate, 250 );
3077
- };
3078
-
3079
- // delay is in seconds
3080
- var fetchDuration = function( delay ) {
3081
- var ytDuration = options.youtubeObject.getDuration();
3082
-
3083
- if ( isNaN( ytDuration ) || ytDuration === 0 ) {
3084
- setTimeout( function() {
3085
- fetchDuration( delay * 2 );
3086
- }, delay*1000 );
3087
- } else {
3088
- // set duration and dispatch ready events
3089
- media.duration = ytDuration;
3090
- media.dispatchEvent( "durationchange" );
3091
-
3092
- media.dispatchEvent( "loadedmetadata" );
3093
- media.dispatchEvent( "loadeddata" );
3094
-
3095
- media.readyState = 4;
3096
-
3097
- timeUpdate();
3098
- media.dispatchEvent( "canplaythrough" );
3099
- }
3100
- };
3101
-
3102
- options.controls = +options.controls === 0 || +options.controls === 1 ? options.controls : 1;
3103
- options.annotations = +options.annotations === 1 || +options.annotations === 3 ? options.annotations : 1;
3104
-
3105
- src = /^.*(?:\/|v=)(.{11})/.exec( media.src )[ 1 ];
3106
-
3107
- query = ( media.src.split( "?" )[ 1 ] || "" )
3108
- .replace( /v=.{11}/, "" );
3109
- query = query.replace( /&t=(?:(\d+)m)?(?:(\d+)s)?/, function( all, minutes, seconds ) {
3110
-
3111
- // Make sure we have real zeros
3112
- minutes = minutes | 0; // bit-wise OR
3113
- seconds = seconds | 0; // bit-wise OR
3114
-
3115
- fragmentStart = ( +seconds + ( minutes * 60 ) );
3116
- return "";
3117
- });
3118
- query = query.replace( /&start=(\d+)?/, function( all, seconds ) {
3119
-
3120
- // Make sure we have real zeros
3121
- seconds = seconds | 0; // bit-wise OR
3122
-
3123
- fragmentStart = seconds;
3124
- return "";
3125
- });
3126
-
3127
- autoPlay = ( /autoplay=1/.test( query ) );
3128
-
3129
- params = query.split( /[\&\?]/g );
3130
- playerVars = { wmode: "transparent" };
3131
-
3132
- for( var i = 0; i < params.length; i++ ) {
3133
- queryStringItem = params[ i ].split( "=" );
3134
- playerVars[ queryStringItem[ 0 ] ] = queryStringItem[ 1 ];
3135
- }
3136
-
3137
- options.youtubeObject = new YT.Player( container.id, {
3138
- height: "100%",
3139
- width: "100%",
3140
- wmode: "transparent",
3141
- playerVars: playerVars,
3142
- videoId: src,
3143
- events: {
3144
- "onReady": function(){
3145
-
3146
- // pulling initial volume states form baseplayer
3147
- lastVolume = media.volume;
3148
- lastMuted = media.muted;
3149
-
3150
- volumeupdate();
3151
-
3152
- paused = media.paused;
3153
- createProperties();
3154
- options.youtubeObject.playVideo();
3155
-
3156
- media.currentTime = fragmentStart;
3157
- // wait to dispatch ready events until we get a duration
3158
- },
3159
- "onStateChange": function( state ){
3160
-
3161
- if ( options.destroyed || state.data === -1 ) {
3162
- return;
3163
- }
3164
-
3165
- // state.data === 2 is for pause events
3166
- // state.data === 1 is for play events
3167
- if ( state.data === 2 ) {
3168
- paused = true;
3169
- media.dispatchEvent( "pause" );
3170
- playerQueue.next();
3171
- } else if ( state.data === 1 && !firstPlay ) {
3172
- paused = false;
3173
- media.dispatchEvent( "play" );
3174
- media.dispatchEvent( "playing" );
3175
- playerQueue.next();
3176
- } else if ( state.data === 0 ) {
3177
- media.dispatchEvent( "ended" );
3178
- } else if ( state.data === 1 && firstPlay ) {
3179
- firstPlay = false;
3180
-
3181
- // pulling initial paused state from autoplay or the baseplayer
3182
- // also need to explicitly set to paused otherwise.
3183
- if ( autoPlay || !media.paused ) {
3184
- paused = false;
3185
- }
3186
-
3187
- if ( paused ) {
3188
- options.youtubeObject.pauseVideo();
3189
- }
3190
-
3191
- fetchDuration( 0.025 );
3192
- }
3193
- },
3194
- "onError": function( error ) {
3195
-
3196
- if ( [ 2, 100, 101, 150 ].indexOf( error.data ) !== -1 ) {
3197
- media.error = {
3198
- customCode: error.data
3199
- };
3200
- media.dispatchEvent( "error" );
3201
- }
3202
- }
3203
- }
3204
- });
3205
-
3206
- var volumeupdate = function() {
3207
-
3208
- if ( options.destroyed ) {
3209
-
3210
- return;
3211
- }
3212
-
3213
- if ( lastMuted !== options.youtubeObject.isMuted() ) {
3214
-
3215
- lastMuted = options.youtubeObject.isMuted();
3216
- media.dispatchEvent( "volumechange" );
3217
- }
3218
-
3219
- if ( lastVolume !== options.youtubeObject.getVolume() ) {
3220
-
3221
- lastVolume = options.youtubeObject.getVolume();
3222
- media.dispatchEvent( "volumechange" );
3223
- }
3224
-
3225
- setTimeout( volumeupdate, 250 );
3226
- };
3227
- };
3594
+ _canPlayType: canPlayType
3595
+ });
3228
3596
 
3229
- if ( onYouTubePlayerAPIReady.ready ) {
3597
+ Popcorn.youtube = function( container, url, options ) {
3598
+ if ( typeof console !== "undefined" && console.warn ) {
3599
+ console.warn( "Deprecated player 'youtube'. Please use Popcorn.HTMLYouTubeVideoElement directly." );
3600
+ }
3230
3601
 
3231
- youtubeInit();
3232
- } else {
3602
+ var media = Popcorn.HTMLYouTubeVideoElement( container ),
3603
+ popcorn = Popcorn( media, options );
3233
3604
 
3234
- onYouTubePlayerAPIReady.waiting.push( youtubeInit );
3235
- }
3236
- },
3237
- _teardown: function( options ) {
3605
+ // Set the src "soon" but return popcorn instance first, so
3606
+ // the caller can listen for error events.
3607
+ setTimeout( function() {
3608
+ media.src = url;
3609
+ }, 0 );
3238
3610
 
3239
- options.destroyed = true;
3611
+ return popcorn;
3612
+ };
3240
3613
 
3241
- var youtubeObject = options.youtubeObject;
3242
- if( youtubeObject ){
3243
- youtubeObject.stopVideo();
3244
- youtubeObject.clearVideo && youtubeObject.clearVideo();
3245
- }
3614
+ Popcorn.youtube.canPlayType = canPlayType;
3246
3615
 
3247
- this.removeChild( document.getElementById( options._container.id ) );
3248
- }
3249
- });
3250
3616
  }( window, Popcorn ));