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
3.8 KiB

(function(e,t,n,o){e.fn.video=function(t){var n,i=e.extend(!0,{},e.fn.video.settings,t),a=arguments||!1;return e(this).each(function(){var r,s=e(this),l=s.find(i.selector.placeholder),c=s.find(i.selector.playButton),u=s.find(i.selector.embed),d=s.data("module-"+i.namespace),f="string"==typeof t,m=i.namespace,p=i.metadata,g=i.className;r={initialize:function(){r.debug("Initializing video"),l.off(".video").on("click."+m,r.play),c.off(".video").on("click."+m,r.play),s.data("module-"+m,r)},change:function(e,t){r.debug("Changing video to ",t),s.data(p.source,e).data(p.flv,t),i.onChange()},reset:function(){r.debug("Clearing video embed and showing placeholder"),s.removeClass(g.active),u.html(" "),l.show(),i.onReset()},play:function(){r.debug("Playing video");var e=s.data(p.source),t=s.data(p.flv);u.html(r.generate.html(e,t)),s.addClass(g.active),i.onPlay()},generate:{html:function(e,t){r.debug("Generating embed html");var n,o="auto"==i.width?s.width():i.width,a="auto"==i.height?s.height():i.height;return"vimeo"==e?n='<iframe src="http://player.vimeo.com/video/'+t+"?="+r.generate.url(e)+'"'+' width="'+o+'" height="'+a+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==e&&(n='<iframe src="http://www.youtube.com/embed/'+t+"?="+r.generate.url(e)+'"'+' width="'+o+'" height="'+a+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'),n},url:function(e){var t=i.api?1:0,n=i.autoplay?1:0,o=i.hd?1:0,a=i.showUI?1:0,r=i.showUI?0:1,s="";return"vimeo"==e?(s="api="+t+"&amp;title="+a+"&amp;byline="+a+"&amp;portrait="+a+"&amp;autoplay="+n,i.color&&(s+="&amp;color="+i.color)):"youtube"==e&&(s="enablejsapi="+t+"&amp;autoplay="+n+"&amp;autohide="+r+"&amp;hq="+o+"&amp;modestbranding=1",i.color&&(s+="&amp;color="+i.color)),s}},debug:function(e,t){i.debug&&(t!==o?console.info(i.moduleName+": "+e,t):console.info(i.moduleName+": "+e))},error:function(e){console.warn(i.moduleName+": "+e)},invoke:function(t,n,a){var s;return a=a||Array.prototype.slice.call(arguments,2),"string"==typeof t&&d!==o&&(t=t.split("."),e.each(t,function(t,n){return e.isPlainObject(d[n])?(d=d[n],!0):e.isFunction(d[n])?(s=d[n],!0):(r.error(i.errors.method),!1)})),e.isFunction(s)?s.apply(n,a):s}},f?n=r.invoke(a[0],this,Array.prototype.slice.call(a,1)):(d&&r.destroy(),r.initialize())}),n!==o?n:this},e.fn.videoPlaylist=function(t,n){var o=e(this),i=e(t),a=i.find(".embed iframe"),r=e.extend({},e.fn.videoPlaylist.settings,n,!0);o.each(function(){var t=e(this),n=r.metadata,a=r.namespace,s=r.className,l={initialize:function(){t.on("click."+a,l.changeVideo)},changeVideo:function(){var a=t.data(n.flv)||!1,l=t.data(n.source)||!1,c=t.data(n.placeholder)||!1;if(a&&l){if(i.data(n.source,l).data(n.flv,a),r.showPlaceholder)i.removeClass(s.active).find(e.fn.video.selector.placeholder).attr("src",c);else try{i.video("play")}catch(u){console.warn("Video Playlist Module: "+r.error.init)}o.removeClass(s.active),t.addClass(s.active)}}};l.initialize()}),r.playFirst&&(o.eq(0).trigger("click"),a.size()>0&&a.attr("src",a.attr("src").replace("autoplay=1","autoplay=0")))},e.fn.video.settings={moduleName:"Video",namespace:"video",debug:!1,metadata:{source:"source",flv:"flv"},onPlay:function(){},onReset:function(){},onChange:function(){},play:function(){},pause:function(){},stop:function(){},width:"auto",height:"auto",autoplay:!1,color:"#442359",hd:!0,showUI:!1,api:!0,errors:{method:"The method you called is not defined"},className:{active:"active"},selector:{embed:".embed",placeholder:".placeholder",playButton:".play"}},e.fn.videoPlaylist.settings={moduleName:"Video Playlist",namespace:"videoPlaylist",source:"vimeo",showPlaceholder:!1,playFirst:!0,metadata:{flv:"flv",source:"source",placeholder:"placeholder"},errors:{init:"The video player you specified was not yet initialized"},className:{active:"active"}}})(jQuery,window,document);