11 lines
No EOL
7.8 KiB
JavaScript
11 lines
No EOL
7.8 KiB
JavaScript
/*
|
|
* # Fomantic UI - 2.8.8
|
|
* https://github.com/fomantic/Fomantic-UI
|
|
* http://fomantic-ui.com/
|
|
*
|
|
* Copyright 2022 Contributors
|
|
* Released under the MIT license
|
|
* http://opensource.org/licenses/MIT
|
|
*
|
|
*/
|
|
!function(E,e,U){"use strict";E.isFunction=E.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),E.fn.embed=function(h){var b,g=E(this),v=g.selector||"",y=(new Date).getTime(),w=[],P=h,C="string"==typeof P,D=[].slice.call(arguments,1);return g.each(function(){var t=E.isPlainObject(h)?E.extend(!0,{},E.fn.embed.settings,h):E.extend({},E.fn.embed.settings),e=t.selector,n=t.className,r=t.sources,u=t.error,a=t.metadata,s=t.namespace,m=t.templates,p="."+s,f="module-"+s,i=E(this),o=(i.find(e.placeholder),i.find(e.icon),i.find(e.embed)),c=this,l=i.data(f),d={initialize:function(){d.debug("Initializing embed"),d.determine.autoplay(),d.create(),d.bind.events(),d.instantiate()},instantiate:function(){d.verbose("Storing instance of module",d),l=d,i.data(f,d)},destroy:function(){d.verbose("Destroying previous instance of embed"),d.reset(),i.removeData(f).off(p)},refresh:function(){d.verbose("Refreshing selector cache"),i.find(e.placeholder),i.find(e.icon),o=i.find(e.embed)},bind:{events:function(){d.has.placeholder()&&(d.debug("Adding placeholder events"),i.on("click"+p,e.placeholder,d.createAndShow).on("click"+p,e.icon,d.createAndShow))}},create:function(){d.get.placeholder()?d.createPlaceholder():d.createAndShow()},createPlaceholder:function(e){var n=d.get.icon(),o=d.get.url();d.generate.embed(o);e=e||d.get.placeholder(),i.html(m.placeholder(e,n)),d.debug("Creating placeholder for embed",e,n)},createEmbed:function(e){d.refresh(),e=e||d.get.url(),o=E("<div/>").addClass(n.embed).html(d.generate.embed(e)).appendTo(i),t.onCreate.call(c,e),d.debug("Creating embed object",o)},changeEmbed:function(e){o.html(d.generate.embed(e))},createAndShow:function(){d.createEmbed(),d.show()},change:function(e,n,o){d.debug("Changing video to ",e,n,o),i.data(a.source,e).data(a.id,n),o?i.data(a.url,o):i.removeData(a.url),d.has.embed()?d.changeEmbed():d.create()},reset:function(){d.debug("Clearing embed and showing placeholder"),d.remove.data(),d.remove.active(),d.remove.embed(),d.showPlaceholder(),t.onReset.call(c)},show:function(){d.debug("Showing embed"),d.set.active(),t.onDisplay.call(c)},hide:function(){d.debug("Hiding embed"),d.showPlaceholder()},showPlaceholder:function(){d.debug("Showing placeholder image"),d.remove.active(),t.onPlaceholderDisplay.call(c)},get:{id:function(){return t.id||i.data(a.id)},placeholder:function(){return t.placeholder||i.data(a.placeholder)},icon:function(){return t.icon||(i.data(a.icon)!==U?i.data(a.icon):d.determine.icon())},source:function(e){return t.source||(i.data(a.source)!==U?i.data(a.source):d.determine.source())},type:function(){var e=d.get.source();return r[e]!==U&&r[e].type},url:function(){return t.url||(i.data(a.url)!==U?i.data(a.url):d.determine.url())}},determine:{autoplay:function(){d.should.autoplay()&&(t.autoplay=!0)},source:function(o){var t=!1;return(o=o||d.get.url())&&E.each(r,function(e,n){if(-1!==o.search(n.domain))return t=e,!1}),t},icon:function(){var e=d.get.source();return r[e]!==U&&r[e].icon},url:function(){var e=t.id||i.data(a.id),n=t.source||i.data(a.source),n=r[n]!==U&&r[n].url.replace("{id}",e);return n&&i.data(a.url,n),n}},set:{active:function(){i.addClass(n.active)}},remove:{data:function(){i.removeData(a.id).removeData(a.icon).removeData(a.placeholder).removeData(a.source).removeData(a.url)},active:function(){i.removeClass(n.active)},embed:function(){o.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){d.debug("Generating embed html");var n,o=d.get.source();return(e=d.get.url(e))?(o=d.generate.parameters(o),n=m.iframe(e,o)):d.error(u.noURL,i),n},parameters:function(e,n){e=r[e]&&r[e].parameters!==U?r[e].parameters(t):{};return(n=n||t.parameters)&&(e=E.extend({},e,n)),e=t.onEmbed(e),d.encode.parameters(e)}},has:{embed:function(){return 0<o.length},placeholder:function(){return t.placeholder||i.data(a.placeholder)}},should:{autoplay:function(){return"auto"===t.autoplay?t.placeholder||i.data(a.placeholder)!==U:t.autoplay}},is:{video:function(){return"video"==d.get.type()}},setting:function(e,n){if(d.debug("Changing setting",e,n),E.isPlainObject(e))E.extend(!0,t,e);else{if(n===U)return t[e];E.isPlainObject(t[e])?E.extend(!0,t[e],n):t[e]=n}},internal:function(e,n){if(E.isPlainObject(e))E.extend(!0,d,e);else{if(n===U)return d[e];d[e]=n}},debug:function(){!t.silent&&t.debug&&(t.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,t.name+":"),d.debug.apply(console,arguments)))},verbose:function(){!t.silent&&t.verbose&&t.debug&&(t.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,t.name+":"),d.verbose.apply(console,arguments)))},error:function(){t.silent||(d.error=Function.prototype.bind.call(console.error,console,t.name+":"),d.error.apply(console,arguments))},performance:{log:function(e){var n,o;t.performance&&(o=(n=(new Date).getTime())-(y||n),y=n,w.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:c,"Execution Time":o})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,500)},display:function(){var e=t.name+":",o=0;y=!1,clearTimeout(d.performance.timer),E.each(w,function(e,n){o+=n["Execution Time"]}),e+=" "+o+"ms",v&&(e+=" '"+v+"'"),1<g.length&&(e+=" ("+g.length+")"),(console.group!==U||console.table!==U)&&0<w.length&&(console.groupCollapsed(e),console.table?console.table(w):E.each(w,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),w=[]}},invoke:function(t,e,n){var r,a,o,i=l;return e=e||D,n=c||n,"string"==typeof t&&i!==U&&(t=t.split(/[\. ]/),r=t.length-1,E.each(t,function(e,n){var o=e!=r?n+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(E.isPlainObject(i[o])&&e!=r)i=i[o];else{if(i[o]!==U)return a=i[o],!1;{if(!E.isPlainObject(i[n])||e==r)return i[n]!==U?a=i[n]:d.error(u.method,t),!1;i=i[n]}}})),E.isFunction(a)?o=a.apply(n,e):a!==U&&(o=a),Array.isArray(b)?b.push(o):b!==U?b=[b,o]:o!==U&&(b=o),a}};C?(l===U&&d.initialize(),d.invoke(P)):(l!==U&&l.invoke("destroy"),d.initialize())}),b!==U?b:this},E.fn.embed.settings={name:"Embed",namespace:"embed",silent:!1,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.color||U,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.color||U,portrait:e.brandedUI,title:e.brandedUI}}}},templates:{iframe:function(e,n){return n&&(e+="?"+n),'<iframe src="'+e+'" width="100%" height="100%" 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:!1,onPause:function(){},onPlay:function(){},onStop:function(){}}}(jQuery,window,void document); |