/*! * # Semantic UI 2.0.0 - Video * http://github.com/semantic-org/semantic-ui/ * * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,n,o,t){"use strict";e.fn.embed=function(o){var r,a=e(this),i=a.selector||"",c=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,s=[].slice.call(arguments,1);return a.each(function(){var m,p=e.isPlainObject(o)?e.extend(!0,{},e.fn.embed.settings,o):e.extend({},e.fn.embed.settings),f=p.selector,h=p.className,g=p.sources,b=p.error,v=p.metadata,y=p.namespace,w=p.templates,C="."+y,P="module-"+y,U=(e(n),e(this)),E=U.find(f.placeholder),S=U.find(f.play),T=U.find(f.embed),j=this,A=U.data(P);m={initialize:function(){m.debug("Initializing embed"),m.create(),m.bind.events(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),A=m,U.data(P,m)},destroy:function(){m.verbose("Destroying previous instance of embed"),m.reset(),U.removeData(P).off(C)},refresh:function(){m.verbose("Refreshing selector cache"),E=U.find(f.placeholder),S=U.find(f.play),T=U.find(f.embed)},bind:{events:function(){m.is.video()&&(m.debug("Adding placeholder events"),U.on("click"+C,f.placeholder,m.createAndShow).on("click"+C,f.play,m.createAndShow))}},create:function(){var e=m.get.placeholder();e?m.createPlaceholder():m.createAndShow()},createPlaceholder:function(e){{var n=m.get.icon(),o=m.get.url();m.generate.embed(o)}e=e||m.get.placeholder(),U.html(w.placeholder(e,n)),m.debug("Creating placeholder for embed",e,n)},createEmbed:function(n){m.refresh(),n=n||m.get.url(),T=e("
").addClass(h.embed).html(m.generate.embed(n)).appendTo(U),m.debug("Creating embed object",T)},createAndShow:function(){m.createEmbed(),m.show()},change:function(e,n,o){m.debug("Changing video to ",e,n,o),U.data(v.source,e).data(v.id,n).data(v.url,o),m.create(),p.onChange.call(j)},reset:function(){m.debug("Clearing embed and showing placeholder"),m.remove.active(),m.remove.embed(),m.showPlaceholder(),p.onReset.call(j)},show:function(){m.debug("Showing embed"),m.set.active(),p.onDisplay.call(j)},hide:function(){m.debug("Hiding embed"),m.showPlaceholder()},showPlaceholder:function(){m.debug("Showing placeholder image"),m.remove.active(),p.onPlaceholderDisplay.call(j)},get:{id:function(){return p.id||U.data(v.id)},placeholder:function(){return p.placeholder||U.data(v.placeholder)},icon:function(){return p.icon?p.icon:U.data(v.icon)!==t?U.data(v.icon):m.determine.icon()},source:function(e){return p.source?p.source:U.data(v.source)!==t?U.data(v.source):m.determine.source()},type:function(){var e=m.get.source();return g[e]!==t?g[e].type:!1},url:function(){return p.url?p.url:U.data(v.url)!==t?U.data(v.url):m.determine.url()}},determine:{source:function(n){var o=!1;return n=n||m.get.url(),n&&e.each(g,function(e,t){return-1!==n.search(t.domain)?(o=e,!1):void 0}),o},icon:function(){var e=m.get.source();return g[e]!==t?g[e].icon:!1},url:function(){var e,n=p.id||U.data(v.id),o=p.source||U.data(v.source);return e=g[o]!==t?g[o].url.replace("{id}",n):!1,e&&U.data(v.url,e),e}},set:{active:function(){U.addClass(h.active)}},remove:{active:function(){U.removeClass(h.active)},embed:function(){T.empty()}},encode:{parameters:function(e){var n,o=[];for(n in e)o.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return o.join("&")}},generate:{embed:function(e){m.debug("Generating embed html");var n,o,t=m.get.source();return e=m.get.url(e),e?(o=m.generate.parameters(t),n=w.iframe(e,o)):m.error(b.noURL,U),n},parameters:function(n,o){var r,a=g[n].parameters!==t?g[n].parameters(p):{};return o&&(r=e.extend({},a,o)),r=p.onEmbed(r),m.encode.parameters(r)}},has:{placeholder:function(){return p.placeholder||U.data(v.placeholder)}},is:{autoplay:function(){return"auto"===p.autoplay?U.data("image")!==t:p.autoplay},video:function(){return"video"==m.get.type()}},setting:function(n,o){if(m.debug("Changing setting",n,o),e.isPlainObject(n))e.extend(!0,p,n);else{if(o===t)return p[n];p[n]=o}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,m,n);else{if(o===t)return m[n];m[n]=o}},debug:function(){p.debug&&(p.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,p.name+":"),m.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,p.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var n,o,t;p.performance&&(n=(new Date).getTime(),t=c||n,o=n-t,c=n,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:j,"Execution Time":o})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var n=p.name+":",o=0;c=!1,clearTimeout(m.performance.timer),e.each(l,function(e,n){o+=n["Execution Time"]}),n+=" "+o+"ms",i&&(n+=" '"+i+"'"),a.length>1&&(n+=" ("+a.length+")"),(console.group!==t||console.table!==t)&&l.length>0&&(console.groupCollapsed(n),console.table?console.table(l):e.each(l,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(n,o,a){var i,c,l,u=A;return o=o||s,a=j||a,"string"==typeof n&&u!==t&&(n=n.split(/[\. ]/),i=n.length-1,e.each(n,function(o,r){var a=o!=i?r+n[o+1].charAt(0).toUpperCase()+n[o+1].slice(1):n;if(e.isPlainObject(u[a])&&o!=i)u=u[a];else{if(u[a]!==t)return c=u[a],!1;if(!e.isPlainObject(u[r])||o==i)return u[r]!==t?(c=u[r],!1):(m.error(b.method,n),!1);u=u[r]}})),e.isFunction(c)?l=c.apply(a,o):c!==t&&(l=c),e.isArray(r)?r.push(l):r!==t?r=[r,l]:l!==t&&(r=l),c}},d?(A===t&&m.initialize(),m.invoke(u)):(A!==t&&A.invoke("destroy"),m.initialize())}),r!==t?r:this},e.fn.embed.settings={name:"Embed",namespace:"embed",debug:!1,verbose:!1,performance:!0,icon:!1,source:!1,url:!1,id:!1,autoplay:"auto",color:"#444444",hd:!0,showUI:!1,onDisplay:function(){},onPlaceholderDisplay:function(){},onReset:function(){},onChange:function(){},onEmbed:function(e){return e},width:"auto",height:"auto",parameters:!1,api:!0,onPause:function(){},onStop:function(){},metadata:{id:"id",icon:"icon",placeholder:"placeholder",source:"source",url:"url"},error:{noURL:"No URL specified",method:"The method you called is not defined"},className:{active:"active",embed:"embed"},selector:{embed:".embed",placeholder:".placeholder",play:".play"}},e.fn.embed.settings.sources={youtube:{name:"youtube",type:"video",icon:"video play",domain:"youtube.com",url:"//www.youtube.com/embed/{id}",parameters:function(e){return{autohide:!e.showUI,autoplay:e.autoplay,color:e.colors||t,hq:e.hd,jsapi:e.api,modestbranding:1}}},vimeo:{name:"vimeo",type:"video",icon:"video play",domain:"vimeo.com",url:"//www.youtube.com/embed/{id}",parameters:function(e){return{api:e.api,autoplay:e.autoplay,byline:e.showUI,color:e.colors||t,portrait:e.showUI,title:e.showUI}}}},e.fn.embed.settings.templates={iframe:function(e,n){return''},placeholder:function(e,n){var o="";return n&&(o+=''),e&&(o+=''),o}}}(jQuery,window,document);