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

11 lines
7.8 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.9.3
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-01-13 13:00:31 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-01-13 13:00:31 +00:00
*
*/
!function(D,e){"use strict";e=void 0!==e&&e.Math===Math?e:globalThis,D.fn.embed=function(h){var b,v=D(this),g=Date.now(),y=[],w=h,P="string"==typeof w,C=[].slice.call(arguments,1);return v.each(function(){var t=D.isPlainObject(h)?D.extend(!0,{},D.fn.embed.settings,h):D.extend({},D.fn.embed.settings),e=t.selector,o=t.className,a=t.sources,d=t.error,r=t.metadata,n=t.namespace,i=t.templates,c="."+n,l="module-"+n,u=D(this),s=(u.find(e.placeholder),u.find(e.icon),u.find(e.embed)),m=this,p=u.data(l),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(l,f)},destroy:function(){f.verbose("Destroying previous instance of embed"),f.reset(),u.removeData(l).off(c)},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"+c,e.placeholder,f.createAndShow).on("click"+c,e.icon,f.createAndShow))}},create:function(){f.get.placeholder()?f.createPlaceholder():f.createAndShow()},createPlaceholder:function(e){var o=f.get.icon();e=e||f.get.placeholder(),u.html(i.placeholder(e,o)),f.debug("Creating placeholder for embed",e,o)},createEmbed:function(e){f.refresh(),e=e||f.get.url(),s=D("<div/>").addClass(o.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,o,n){f.debug("Changing video to ",e,o,n),u.data(r.source,e).data(r.id,o),n?u.data(r.url,n):u.removeData(r.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(r.id)},placeholder:function(){return t.placeholder||u.data(r.placeholder)},icon:function(){return t.icon||(void 0!==u.data(r.icon)?u.data(r.icon):f.determine.icon())},source:function(e){return t.source||(void 0!==u.data(r.source)?u.data(r.source):f.determine.source())},type:function(){var e=f.get.source();return void 0!==a[e]&&a[e].type},url:function(){return t.url||(void 0!==u.data(r.url)?u.data(r.url):f.determine.url())}},determine:{autoplay:function(){f.should.autoplay()&&(t.autoplay=!0)},source:function(n){var t=!1;return(n=n||f.get.url())&&D.each(a,function(e,o){if(-1!==n.search(o.domain))return t=e,!1}),t},icon:function(){var e=f.get.source();return void 0!==a[e]&&a[e].icon},url:function(){var e=t.id||u.data(r.id),o=t.source||u.data(r.source),o=void 0!==a[o]&&a[o].url.replace("{id}",e);return o&&u.data(r.url,o),o}},set:{active:function(){u.addClass(o.active)}},remove:{data:function(){u.removeData(r.id).removeData(r.icon).removeData(r.placeholder).removeData(r.source).removeData(r.url)},active:function(){u.removeClass(o.active)},embed:function(){s.empty()}},encode:{parameters:function(e){var o,n=[];for(o in e)n.push(encodeURIComponent(o)+"="+encodeURIComponent(e[o]));return n.join("&amp;")}},generate:{embed:function(e){f.debug("Generating embed html");var o,n=f.get.source();return(e=f.get.url(e))?(n=f.generate.parameters(n),o=i.iframe(e,n)):f.error(d.noURL,u),o},parameters:function(e,o){e=a[e]&&void 0!==a[e].parameters?a[e].parameters(t):{};return(o=o||t.parameters)&&(e=D.extend({},e,o)),e=t.onEmbed(e),f.encode.parameters(e)}},has:{embed:function(){return 0<s.length},placeholder:function(){return t.placeholder||u.data(r.placeholder)}},should:{autoplay:function(){return"auto"===t.autoplay?t.placeholder||void 0!==u.data(r.placeholder):t.autoplay}},is:{video:function(){return"video"===f.get.type()}},setting:function(e,o){if(f.debug("Changing