You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
4.5 KiB
1 lines
4.5 KiB
!function(a,b,c,d){a.fn.video=function(b){var c,e=a(this),f=a.isPlainObject(b)?a.extend(!0,{},a.fn.video.settings,b):a.fn.video.settings,g=e.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1),m=f.selector,n=f.className,o=f.error,p=f.metadata,q=f.namespace,r="."+q,s=q+"-module";return e.each(function(){var b,e=a(this),q=e.find(m.placeholder),t=e.find(m.playButton),u=e.find(m.embed),v=this,w=e.data(s);b={initialize:function(){b.debug("Initializing video"),q.on("click"+r,b.play),t.on("click"+r,b.play),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),w=b,e.data(s,b)},destroy:function(){b.verbose("Destroying previous instance of video"),e.removeData(s).off(r)},change:function(a,c,d){b.debug("Changing video to ",a,c,d),e.data(p.source,a).data(p.id,c).data(p.url,d),f.onChange()},reset:function(){b.debug("Clearing video embed and showing placeholder"),e.removeClass(n.active),u.html(" "),q.show(),f.onReset()},play:function(){b.debug("Playing video");var a=e.data(p.source)||!1,c=e.data(p.url)||!1,d=e.data(p.id)||!1;u.html(b.generate.html(a,d,c)),e.addClass(n.active),f.onPlay()},generate:{html:function(a,c,d){b.debug("Generating embed html");var g,h="auto"==f.width?e.width():f.width,i="auto"==f.height?e.height():f.height;return a&&c?"vimeo"==a?g='<iframe src="http://player.vimeo.com/video/'+c+"?="+b.generate.url(a)+'"'+' width="'+h+'" height="'+i+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==a&&(g='<iframe src="http://www.youtube.com/embed/'+c+"?="+b.generate.url(a)+'"'+' width="'+h+'" height="'+i+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'):d?g='<iframe src="'+d+'"'+' width="'+h+'" height="'+i+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':b.error(o.noVideo),g},url:function(a){var b=f.api?1:0,c=f.autoplay?1:0,d=f.hd?1:0,e=f.showUI?1:0,g=f.showUI?0:1,h="";return"vimeo"==a&&(h="api="+b+"&title="+e+"&byline="+e+"&portrait="+e+"&autoplay="+c,f.color&&(h+="&color="+f.color)),"ustream"==a?(h="autoplay="+c,f.color&&(h+="&color="+f.color)):"youtube"==a&&(h="enablejsapi="+b+"&autoplay="+c+"&autohide="+g+"&hq="+d+"&modestbranding=1",f.color&&(h+="&color="+f.color)),h}},setting:function(b,c){return c===d?f[b]:(a.isPlainObject(b)?a.extend(!0,f,b):f[b]=c,void 0)},internal:function(c,e){return e===d?b[c]:(a.isPlainObject(c)?a.extend(!0,b,c):b[c]=e,void 0)},debug:function(){f.debug&&(f.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,f.moduleName+":"),b.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,f.moduleName+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,f.moduleName+":"),b.error.apply(console,arguments)},performance:{log:function(a){var c,d,e;f.performance&&(c=(new Date).getTime(),e=h||c,d=c-e,h=c,i.push({Element:v,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":d})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var c=f.moduleName+":",e=0;h=!1,clearTimeout(b.performance.timer),a.each(i,function(a,b){e+=b["Execution Time"]}),c+=" "+e+"ms",g&&(c+=" '"+g+"'"),(console.group!==d||console.table!==d)&&i.length>0&&(console.groupCollapsed(c),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(c,e,f){var g,h;return e=e||l,f=v||f,"string"==typeof c&&w!==d&&(c=c.split(/[\. ]/),g=c.length-1,a.each(c,function(c,e){a.isPlainObject(w[e])&&c!=g?w=w[e]:w[e]!==d?h=w[e]:b.error(o.method)})),a.isFunction(h)?h.apply(f,e):h||!1}},k?(w===d&&b.initialize(),c=b.invoke(j)):(w!==d&&b.destroy(),b.initialize())}),c?c:this},a.fn.video.settings={moduleName:"Video",namespace:"video",debug:!0,verbose:!0,performance:!0,metadata:{source:"source",id:"id",url:"url"},onPlay:function(){},onReset:function(){},onChange:function(){},onPause:function(){},onStop:function(){},width:"auto",height:"auto",autoplay:!1,color:"#442359",hd:!0,showUI:!1,api:!0,error:{noVideo:"No video specified",method:"The method you called is not defined"},className:{active:"active"},selector:{embed:".embed",placeholder:".placeholder",playButton:".play"}}}(jQuery,window,document);
|