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.
11 lines
7.3 KiB
11 lines
7.3 KiB
/*!
|
|
* # Semantic UI 2.1.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,r){"use strict";e.fn.embed=function(o){var t,a=e(this),i=a.selector||"",c=(new Date).getTime(),l=[],d=arguments[0],u="string"==typeof d,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,b=p.sources,g=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.icon),T=U.find(f.embed),j=this,A=U.data(P);m={initialize:function(){m.debug("Initializing embed"),m.determine.autoplay(),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.icon),T=U.find(f.embed)},bind:{events:function(){m.has.placeholder()&&(m.debug("Adding placeholder events"),U.on("click"+C,f.placeholder,m.createAndShow).on("click"+C,f.icon,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("<div/>").addClass(h.embed).html(m.generate.embed(n)).appendTo(U),p.onCreate.call(j,n),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()},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)!==r?U.data(v.icon):m.determine.icon()},source:function(e){return p.source?p.source:U.data(v.source)!==r?U.data(v.source):m.determine.source()},type:function(){var e=m.get.source();return b[e]!==r?b[e].type:!1},url:function(){return p.url?p.url:U.data(v.url)!==r?U.data(v.url):m.determine.url()}},determine:{autoplay:function(){m.should.autoplay()&&(p.autoplay=!0)},source:function(n){var o=!1;return n=n||m.get.url(),n&&e.each(b,function(e,r){return-1!==n.search(r.domain)?(o=e,!1):void 0}),o},icon:function(){var e=m.get.source();return b[e]!==r?b[e].icon:!1},url:function(){var e,n=p.id||U.data(v.id),o=p.source||U.data(v.source);return e=b[o]!==r?b[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,r=m.get.source();return e=m.get.url(e),e?(o=m.generate.parameters(r),n=w.iframe(e,o)):m.error(g.noURL,U),n},parameters:function(n,o){var t=b[n]&&b[n].parameters!==r?b[n].parameters(p):{};return o=o||p.parameters,o&&(t=e.extend({},t,o)),t=p.onEmbed(t),m.encode.parameters(t)}},has:{placeholder:function(){return p.placeholder||U.data(v.placeholder)}},should:{autoplay:function(){return"auto"===p.autoplay?p.placeholder||U.data(v.placeholder)!==r:p.autoplay}},is:{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===r)return p[n];p[n]=o}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,m,n);else{if(o===r)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,r;p.performance&&(n=(new Date).getTime(),r=c||n,o=n-r,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!==r||console.table!==r)&&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,d=A;return o=o||s,a=j||a,"string"==typeof n&&d!==r&&(n=n.split(/[\. ]/),i=n.length-1,e.each(n,function(o,t){var a=o!=i?t+n[o+1].charAt(0).toUpperCase()+n[o+1].slice(1):n;if(e.isPlainObject(d[a])&&o!=i)d=d[a];else{if(d[a]!==r)return c=d[a],!1;if(!e.isPlainObject(d[t])||o==i)return d[t]!==r?(c=d[t],!1):(m.error(g.method,n),!1);d=d[t]}})),e.isFunction(c)?l=c.apply(a,o):c!==r&&(l=c),e.isArray(t)?t.push(l):t!==r?t=[t,l]:l!==r&&(t=l),c}},u?(A===r&&m.initialize(),m.invoke(d)):(A!==r&&A.invoke("destroy"),m.initialize())}),t!==r?t: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,brandedUI:!1,parameters:!1,onDisplay:function(){},onPlaceholderDisplay:function(){},onReset:function(){},onCreate:function(e){},onEmbed:function(e){return e},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",icon:".icon"},sources:{youtube:{name:"youtube",type:"video",icon:"video play",domain:"youtube.com",url:"//www.youtube.com/embed/{id}",parameters:function(e){return{autohide:!e.brandedUI,autoplay:e.autoplay,color:e.colors||r,hq:e.hd,jsapi:e.api,modestbranding:!e.brandedUI}}},vimeo:{name:"vimeo",type:"video",icon:"video play",domain:"vimeo.com",url:"//player.vimeo.com/video/{id}",parameters:function(e){return{api:e.api,autoplay:e.autoplay,byline:e.brandedUI,color:e.colors||r,portrait:e.brandedUI,title:e.brandedUI}}}},templates:{iframe:function(e,n){return'<iframe src="'+e+"?="+n+'" width="100%" height="100%" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'},placeholder:function(e,n){var o="";return n&&(o+='<i class="'+n+' icon"></i>'),e&&(o+='<img class="placeholder" src="'+e+'">'),o}},api:!0,onPause:function(){},onPlay:function(){},onStop:function(){}}}(jQuery,window,document);
|