|
|
!function(a,b,c,d){"use strict";a.fn.video=function(c){{var e,f=a(this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)}}return f.each(function(){var m,n=a.isPlainObject(c)?a.extend(!0,{},a.fn.video.settings,c):a.extend({},a.fn.video.settings),o=n.selector,p=n.className,q=n.error,r=n.metadata,s=n.namespace,t=n.templates,u="."+s,v="module-"+s,w=(a(b),a(this)),x=w.find(o.placeholder),y=w.find(o.playButton),z=w.find(o.embed),A=this,B=w.data(v);m={initialize:function(){m.debug("Initializing video"),m.create(),x.on("click"+u,m.play),y.on("click"+u,m.play),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),B=m,w.data(v,m)},create:function(){var a=w.data(r.image),b=t.video(a);w.html(b),m.refresh(),a||m.play(),m.debug("Creating html for video element",b)},destroy:function(){m.verbose("Destroying previous instance of video"),w.removeData(v).off(u),x.off(u),y.off(u)},refresh:function(){m.verbose("Refreshing selector cache"),x=w.find(o.placeholder),y=w.find(o.playButton),z=w.find(o.embed)},change:function(a,b,c){m.debug("Changing video to ",a,b,c),w.data(r.source,a).data(r.id,b).data(r.url,c),n.onChange()},reset:function(){m.debug("Clearing video embed and showing placeholder"),w.removeClass(p.active),z.html(" "),x.show(),n.onReset()},play:function(){m.debug("Playing video");var a=w.data(r.source)||!1,b=w.data(r.url)||!1,c=w.data(r.id)||!1;z.html(m.generate.html(a,c,b)),w.addClass(p.active),n.onPlay()},get:{source:function(a){return"string"!=typeof a?!1:-1!==a.search("youtube.com")?"youtube":-1!==a.search("vimeo.com")?"vimeo":!1},id:function(a){return n.regExp.youtube.test(a)?a.match(n.regExp.youtube)[1]:n.regExp.vimeo.test(a)?a.match(n.regExp.vimeo)[2]:!1}},generate:{html:function(a,b,c){m.debug("Generating embed html");var d;return a=a||n.source,b=b||n.id,a&&b||c?(a&&b||(a=m.get.source(c),b=m.get.id(c)),"vimeo"==a?d='<iframe src="http://player.vimeo.com/video/'+b+"?="+m.generate.url(a)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==a&&(d='<iframe src="http://www.youtube.com/embed/'+b+"?="+m.generate.url(a)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>')):m.error(q.noVideo),d},url:function(a){var b=n.api?1:0,c="auto"===n.autoplay?w.data("image")!==d:n.autoplay,e=n.hd?1:0,f=n.showUI?1:0,g=n.showUI?0:1,h="";return"vimeo"==a&&(h="api="+b+"&title="+f+"&byline="+f+"&portrait="+f+"&autoplay="+c,n.color&&(h+="&color="+n.color)),"ustream"==a?(h="autoplay="+c,n.color&&(h+="&color="+n.color)):"youtube"==a&&(h="enablejsapi="+b+"&autoplay="+c+"&autohide="+g+"&hq="+e+"&modestbranding=1",n.color&&(h+="&color="+n.color)),h}},setting:function(b,c){if(m.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,n,b);else{if(c===d)return n[b];n[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,m,b);else{if(c===d)return m[b];m[b]=c}},debug:function(){n.debug&&(n.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,n.name+":"),m.debug.apply(console,arguments)))},verbose:function(){n.verbose&&n.debug&&(n.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,n.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,n.name+":"),m.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;n.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Element:A,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var b=n.name+":",c=0;h=!1,clearTimeout(m.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms
|