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 s,r=e(this),l=r.find(i.selector.placeholder),c=r.find(i.selector.playButton),u=r.find(i.selector.embed),d=r.data("module-"+i.namespace),f="string"==typeof t,p=i.namespace,m=i.metadata,g=i.className;s={initialize:function(){s.debug("Initializing video"),l.off(".video").on("click."+p,s.play),c.off(".video").on("click."+p,s.play),r.data("module-"+p,s)},change:function(e,t){s.debug("Changing video to ",t),r.data(m.source,e).data(m.flv,t),i.onChange()},reset:function(){s.debug("Clearing video embed and showing placeholder"),r.removeClass(g.active),u.html(" "),l.show(),i.onReset()},play:function(){s.debug("Playing video");var e=r.data(m.source),t=r.data(m.flv);u.html(s.generate.html(e,t)),r.addClass(g.active),i.onPlay()},generate:{html:function(e,t){s.debug("Generating embed html");var n,o="auto"==i.width?r.width():i.width,a="auto"==i.height?r.height():i.height;return"vimeo"==e?n='<iframe src="http://player.vimeo.com/video/'+t+"?="+s.generate.url(e)+'"'+' width="'+o+'" height="'+a+'"'+' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==e&&(n='<iframe src="http://www.youtube.com/embed/'+t+"?="+s.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,s=i.showUI?0:1,r="";return"vimeo"==e?(r="api="+t+"&amp;title="+a+"&amp;byline="+a+"&amp;portrait="+a+"&amp;autoplay="+n,i.color&&(r+="&amp;color="+i.color)):"youtube"==e&&(r="enablejsapi="+t+"&amp;autoplay="+n+"&amp;autohide="+s+"&amp;hq="+o+"&amp;modestbranding=1",i.color&&(r+="&amp;color="+i.color)),r}},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 r;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])?(r=d[n],!0):(s.error(i.errors.method),!1)})),e.isFunction(r)?r.apply(n,a):r}},f?n=s.invoke(a[0],this,Array.prototype.slice.call(a,1)):(d&&s.destroy(),s.initialize())}),n!==o?n:this},e.fn.videoPlaylist=function(t,n){var o=e(this),i=e(t),a=i.find(".embed iframe"),s=e.extend({},e.fn.videoPlaylist.settings,n,!0);o.each(function(){var t=e(this),n=s.metadata,a=s.namespace,r=s.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),s.showPlaceholder)i.removeClass(r.active).find(e.fn.video.selector.placeholder).attr("src",c);else try{i.video("play")}catch(u){console.warn("Video Playlist Module: "+s.error.init)}o.removeClass(r.active),t.addClass(r.active)}}};l.initialize()}),s.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);