wishthis/node_modules/fomantic-ui/dist/components/embed.min.js

11 lines
8 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-08-31 14:34:36 +00:00
* # Fomantic UI - 2.9.0-beta.311+116f84b
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-06-08 10:36:39 +00:00
* Copyright 2022 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-08-31 14:34:36 +00:00
!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,c=t.error,a=t.metadata,o=t.namespace,i=t.templates,l="."+o,d="module-"+o,u=E(this),s=(u.find(e.placeholder),u.find(e.icon),u.find(e.embed)),m=this,p=u.data(d),f={initialize:function(){f.debug("Initializing embed"),f.determine.autoplay(),f.create(),f.bind.events(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),p=f,u.data(d,f)},destroy:function(){f.verbose("Destroying previous instance of embed"),f.reset(),u.removeData(d).off(l)},refresh:function(){f.verbose("Refreshing selector cache"),u.find(e.placeholder),u.find(e.icon),s=u.find(e.embed)},bind:{events:function(){f.has.placeholder()&&(f.debug("Adding placeholder events"),u.on("click"+l,e.placeholder,f.createAndShow).on("click"+l,e.icon,f.createAndShow))}},create:function(){f.get.placeholder()?f.createPlaceholder():f.createAndShow()},createPlaceholder:function(e){var n=f.get.icon(),o=f.get.url();f.generate.embed(o);e=e||f.get.placeholder(),u.html(i.placeholder(e,n)),f.debug("Creating placeholder for embed",e,n)},createEmbed:function(e){f.refresh(),e=e||f.get.url(),s=E("<div/>").addClass(n.embed).html(f.generate.embed(e)).appendTo(u),t.onCreate.call(m,e),f.debug("Creating embed object",s)},changeEmbed:function(e){s.html(f.generate.embed(e))},createAndShow:function(){f.createEmbed(),f.show()},change:function(e,n,o){f.debug("Changing video to ",e,n,o),u.data(a.source,e).data(a.id,n),o?u.data(a.url,o):u.removeData(a.url),f.has.embed()?f.changeEmbed():f.create()},reset:function(){f.debug("Clearing embed and showing placeholder"),f.remove.data(),f.remove.active(),f.remove.embed(),f.showPlaceholder(),t.onReset.call(m)},show:function(){f.debug("Showing embed"),f.set.active(),t.onDisplay.call(m)},hide:function(){f.debug("Hiding embed"),f.showPlaceholder()},showPlaceholder:function(){f.debug("Showing placeholder image"),f.remove.active(),t.onPlaceholderDisplay.call(m)},get:{id:function(){return t.id||u.data(a.id)},placeholder:function(){return t.placeholder||u.data(a.placeholder)},icon:function(){return t.icon||(u.data(a.icon)!==U?u.data(a.icon):f.determine.icon())},source:function(e){return t.source||(u.data(a.source)!==U?u.data(a.source):f.determine.source())},type:function(){var e=f.get.source();return r[e]!==U&&r[e].type},url:function(){return t.url||(u.data(a.url)!==U?u.data(a.url):f.determine.url())}},determine:{autoplay:function(){f.should.autoplay()&&(t.autoplay=!0)},source:function(o){var t=!1;return(o=o||f.get.url())&&E.each(r,function(e,n){if(-1!==o.search(n.domain))return t=e,!1}),t},icon:function(){var e=f.get.source();return r[e]!==U&&r[e].icon},url:function(){var e=t.id||u.data(a.id),n=t.source||u.data(a.source),n=r[n]!==U&&r[n].url.replace("{id}",e);return n&&u.data(a.url,n),n}},set:{active:function(){u.addClass(n.active)}},remove:{data:function(){u.removeData(a.id).removeData(a.icon).removeData(a.placeholder).removeData(a.source).removeData(a.url)},active:function(){u.removeClass(n.active)},embed:function(){s.empty()}},encode:{parameters:function(e){var n,o=[];for(n in e)o.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return o.join("&amp;")}},generate:{embed:function(e){f.debug("Generating embed html");var n,o=f.get.source();return(e=f.get.url(e))?(o=f.generate.parameters(o),n=i.iframe(e,o)):f.error(c.noURL,u),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),f.encode.parameters(e)}},has:{embed:function(){return 0<s.length},placeholder:function(){return t.placeholder||u.data(a.placeholder)}},should:{autoplay:funct