From 73d69e934312249821aba37cb362924bd4c2658d Mon Sep 17 00:00:00 2001 From: Orest Bida Date: Sun, 8 Sep 2024 19:15:52 +0200 Subject: [PATCH] build: rebuild dist version --- dist/iframemanager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/iframemanager.js b/dist/iframemanager.js index afd491a..507c9c9 100644 --- a/dist/iframemanager.js +++ b/dist/iframemanager.js @@ -1,6 +1,6 @@ /*! - * iframemanager v1.2.5 + * iframemanager v1.3.0 * Author Orest Bida * Released under the MIT License */ -(()=>{const e='click',t='{data-id}',o='accept',n='reject',c='c-h-n',i='c-h-b',s='show-ph';let r,a,l,f,d,u={},m={},v={},p='',h={},b=new Map,w='api';const _=['onload','onerror','src','params'],g=e=>'function'==typeof e,$=e=>'string'==typeof e,S=e=>a.createElement(e),T=()=>S('div'),x=()=>{const e=S('button');return e.type='button',e},y=(e,t)=>e.className=t,I=(e,t)=>e.classList.add(t),P=(e,t)=>e.appendChild(t),D=e=>e&&Object.keys(e)||[],k=(e,t)=>{for(const o in t)C(e,o,t[o])},E=e=>{const t=e.dataset,o={},n='data-iframe-',c=e.getAttributeNames().filter((e=>e.slice(0,12)===n)).map((e=>e.slice(12))),i=e.querySelector('[data-placeholder]'),s=i&&i.hasAttribute('data-visible');s&&i.removeAttribute('data-visible');const r=i&&i.cloneNode(!0);for(const a of c)o[a]=e.getAttribute(n+a);return{t:t.id,o:t.title,i:t.thumbnail,l:t.params,u:e,m:null,v:i,p:r,h:null,_:!1,g:!1,$:!0,S:'widget'in t,T:s,I:o}},M=(e,t)=>{const o=u[e];if('IntersectionObserver'in r){const e=new IntersectionObserver((n=>{for(const c of n)c.isIntersecting&&(O(t,o[c.target.dataset.index]),e.unobserve(c.target))}));for(const t of o)e.observe(t.u)}},O=(e,o)=>{const n=e=>{o.h.style.backgroundImage=`url('${e}')`;const t=new Image;t.onload=()=>I(o.h,'loaded'),t.src=e};if($(o.i))''!==o.i&&n(o.i);else if(g(e))e(o.t,(e=>n(e)));else if($(e)){const c=e.replace(t,o.t);n(c)}},j=(e,o)=>{if(e._)return;if(e._=!0,e.v){const t=e.p.cloneNode(!0);e.v.replaceWith(t),e.v=t}const n=o.iframe;if(g(o.onAccept))return void o.onAccept(e.u,(t=>{if(!(t instanceof HTMLIFrameElement))return!1;k(t,n),k(t,e.I),e.P=t,e._=!0,I(e.u,i),(!e.T||e.S)&&I(e.u,s)}));e.P=S('iframe');const c=o.iframe,r=e.l||c&&c.params;let a=(o.embedUrl||'').replace(t,e.t);e.o&&(e.P.title=e.o),r&&$(r)&&(a+='?'===r.slice(0,1)?r:`?${r}`),e.P.onload=()=>{I(e.u,i),e.P.onload=void 0,g(n&&n.onload)&&n.onload(e.t,e.P)},k(e.P,n),k(e.P,e.I),e.P.src=a,P(e.m,e.P)},C=(e,t,o)=>{_.includes(t)||e.setAttribute(t,o)},L=e=>{I(e.u,c),e.$=!1},N=e=>{e.u.classList.remove(c,i,s),e.$=!0},A=e=>(e=a.cookie.match(`(^|;)\\s*${e}\\s*=\\s*([^;]+)`))?e.pop():'',F=(t,o,n)=>{const i=u[t],s=o.languages;i.forEach((i=>{if(!i.g&&s){const r=s[p],l=r&&r.loadBtn,f=r&&r.notice,d=r&&r.loadAllBtn,u=a.createElement('div'),m=T(),v=T(),h=T(),b=T();y(u,'cll'),i.m=u;const _=()=>{L(i),j(i,o)};if(l){const t=x();t.textContent=l,y(t,'c-l-b'),t.addEventListener(e,_),P(b,t)}if(d){const o=x();o.textContent=d,y(o,l?'c-la-b':'c-l-b'),o.addEventListener(e,(()=>{_(),w=e,q.acceptService(t)})),P(b,o)}const g=T(),D=T(),k=T(),E=T(),M=T();y(g,'cc-text'),y(E,'c-bg-i'),i.h=E,y(k,'c-ld'),$(i.i)&&''===i.i||y(D,'c-bg');const O=i.o,C=a.createDocumentFragment();if(O){const e=S('span');y(e,'c-tl'),e.insertAdjacentHTML('beforeend',O),P(C,e)}P(g,C),m&&g.insertAdjacentHTML('beforeend',f||''),P(v,g),y(M,'c-t-cn'),y(v,'c-n-t'),y(h,'c-n-c'),y(m,'c-nt'),y(b,'c-n-a'),P(M,v),(l||d)&&P(M,b),P(h,M),P(m,h),P(D,E),P(u,m),(o.thumbnailUrl||i.i)&&P(u,D),P(u,k),n&&I(i.u,c),i.u.prepend(u),i.g=!0,setTimeout((()=>I(i.u,'c-an')),20)}}))},G=(e,t)=>{const o=u[e];o.forEach((n=>{n._||((e,n)=>{m[n]||(m[n]=new IntersectionObserver((e=>{if(v[n])m[n].disconnect();else for(let c=0;c{const i=e[c].target,s=i.dataset.index;j(o[s],t),setTimeout((()=>{L(o[s])}),50*c),m[n].unobserve(i)})(c)}))),m[n].observe(e)})(n.u,e)}))},H=(e,t)=>e in t?e:D(t).length>0?p in t?p:D(t)[0]:void 0,J=(e,t)=>{const{cookie:o}=t;A(o.name)||(e=>{const{hostname:t,protocol:o}=location,n=e.name,c=new Date,i=e.path||'/',s=864e5*(e.expiration||182),r=e.sameSite||'Lax',l=e.domain||t;c.setTime(c.getTime()+s);let f=n+'=1'+(0!==s?`; Expires=${c.toUTCString()}`:'')+`; Path=${i}`+`; SameSite=${r}`;l.indexOf('.')>-1&&(f+=`; Domain=${l}`),'https:'===o&&(f+='; Secure'),a.cookie=f})(o),G(e,t)},V=(e,t)=>{const{cookie:o}=t;A(o.name)&&(e=>{const t=e.name,o=e.path||'/',n=e.domain||location.hostname;a.cookie=`${t}=; Path=${o}; Domain=${n}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`})(o),((e,t)=>{const o=u[e];for(let n=0;n{var n;o[e]._&&(g(t.onReject)?(t.onReject(o[e].P,o[e].u,(()=>N(o[e]))),o[e]._=!1):((n=o[e]).P&&n.P.remove(),n._=!1)),N(o[e])})(n)})(e,t)},W=(e,t,o)=>{g(d)&&d({eventSource:{type:w,service:e,action:t},changedServices:o})},q={acceptService:e=>{const t=[];if('all'===e){for(const e of f)v[e]=!1,b.get(e)||(b.set(e,!0),J(e,h[e]),t.push(e));t.length>0&&W(e,o,t)}else f.includes(e)&&(v[e]=!1,b.get(e)||(b.set(e,!0),J(e,h[e]),t.push(e),W(e,o,t)));w='api'},rejectService:e=>{const t=[];if('all'===e){for(const e of f)v[e]=!0,V(e,h[e]),b.get(e)&&(b.set(e,!1),t.push(e));t.length>0&&W(e,n,t)}else f.includes(e)&&(v[e]=!0,V(e,h[e]),b.get(e)&&(b.set(e,!1),t.push(e),W(e,n,t)))},childExists:async({parent:e=r,childProperty:t,childSelector:o='iframe',timeout:n=1e3,maxTimeout:c=15e3})=>{let i=1;const s=t?()=>e[t]:()=>e.querySelector(o);return new Promise((e=>{const t=()=>{if(s()||i++*n>c)return e(void 0!==s());setTimeout(t,n)};t()}))},getState:()=>({services:new Map(b),acceptedServices:[...b].filter((([,e])=>!!e)).map((([e])=>e))}),getConfig:()=>l,run:e=>{if(a=document,r=window,l=e,h=l.services,d=l.onChange,f=D(h),0===f.length)return;p=l.currLang;const t=h[f[0]].languages;!0===l.autoLang?p=H(navigator.language.slice(0,2).toLowerCase(),t):$(l.currLang)&&(p=H(l.currLang,t));for(const o of f){const e=h[o],t=e.cookie=e.cookie||{},n=t.name=t.name||`im_${o}`,c=A(n);b.set(o,!!c),u[o]=[];const i=a.querySelectorAll(`div[data-service="${o}"]`),s=i.length;if(0!==s){for(let e=0;eq)})(); +(()=>{const e='api',t='click',o='{data-id}',n='accept',c='reject',i='c-h-n',s='c-h-b',r='show-ph';let a,l,f,d,v={},u={},m={},w={},p='',h={},b=[],_=new Map,g=e;const $=['onload','onerror','src','params'],S=e=>'function'==typeof e,x=e=>'string'==typeof e,T=e=>l.createElement(e),y=()=>T('div'),I=()=>{const e=T('button');return e.type='button',e},P=(e,t)=>e.className=t,D=(e,t)=>e.classList.add(t),M=(e,t)=>e.appendChild(t),k=e=>e&&Object.keys(e)||[],E=(e,t)=>{for(const o in t)N(e,o,t[o])},O=e=>{const t=e.dataset,o={},n='data-iframe-',c=e.getAttributeNames().filter((e=>e.slice(0,12)===n)).map((e=>e.slice(12))),i=e.querySelector('[data-placeholder]'),s=i&&i.hasAttribute('data-visible');s&&i.removeAttribute('data-visible');const r=i&&i.cloneNode(!0);for(const a of c)o[a]=e.getAttribute(n+a);return{t:t.id,o:t.title,i:t.thumbnail,l:t.params,v:e,u:null,m:i,p:r,h:null,_:!1,$:!1,S:!0,T:'widget'in t,I:s,P:o}},j=(e,t)=>{const o=v[e];'IntersectionObserver'in a&&(e=>{m[e]=new IntersectionObserver((n=>{for(const c of n)c.isIntersecting&&(C(t,o[c.target.dataset.index]),m[e].unobserve(c.target))}));for(const t of o)m[e].observe(t.v)})(e)},C=(e,t)=>{const n=e=>{t.h.style.backgroundImage=`url('${e}')`;const o=new Image;o.onload=()=>D(t.h,'loaded'),o.src=e};if(x(t.i))''!==t.i&&n(t.i);else if(S(e))e(t.t,(e=>n(e)));else if(x(e)){const c=e.replace(o,t.t);n(c)}},L=(e,t)=>{if(e._)return;if(e._=!0,e.m){const t=e.p.cloneNode(!0);e.m.replaceWith(t),e.m=t}const n=t.iframe;if(S(t.onAccept))return void t.onAccept(e.v,(t=>{if(!(t instanceof HTMLIFrameElement))return!1;E(t,n),E(t,e.P),e.D=t,e._=!0,D(e.v,s),(!e.I||e.T)&&D(e.v,r)}));e.D=T('iframe');const c=t.iframe,i=e.l||c&&c.params;let a=t.embedUrl||'';S(a)&&(a=String(a()));let l=a.replace(o,e.t);e.o&&(e.D.title=e.o),i&&x(i)&&(l+='?'===i.slice(0,1)?i:`?${i}`),e.D.onload=()=>{D(e.v,s),e.D.onload=void 0,S(n&&n.onload)&&n.onload(e.t,e.D)},E(e.D,n),E(e.D,e.P),e.D.src=l,M(e.u,e.D)},N=(e,t,o)=>{$.includes(t)||e.setAttribute(t,o)},A=e=>{D(e.v,i),e.S=!1},F=e=>{e.v.classList.remove(i,s,r),e.S=!0},G=e=>(e=l.cookie.match(`(^|;)\\s*${e}\\s*=\\s*([^;]+)`))?e.pop():'',H=(e,n,c)=>{const s=v[e],r=n.languages;s.forEach((s=>{if(!s.$&&r){const a=r[p],f=a&&a.loadBtn,d=a&&(a.notice||'').replace(o,s.t),v=a&&a.loadAllBtn,u=l.createElement('div'),m=y(),w=y(),h=y(),b=y();P(u,'cll'),s.u=u;const _=()=>{A(s),L(s,n)};if(f){const e=I();e.textContent=f,P(e,'c-l-b'),e.addEventListener(t,_),M(b,e)}if(v){const o=I();o.textContent=v,P(o,f?'c-la-b':'c-l-b'),o.addEventListener(t,(()=>{_(),g=t,K.acceptService(e)})),M(b,o)}const $=y(),S=y(),k=y(),E=y(),O=y();P($,'cc-text'),P(E,'c-bg-i'),s.h=E,P(k,'c-ld'),x(s.i)&&''===s.i||P(S,'c-bg');const j=s.o,C=l.createDocumentFragment();if(j){const e=T('span');P(e,'c-tl'),e.insertAdjacentHTML('beforeend',j),M(C,e)}M($,C),m&&$.insertAdjacentHTML('beforeend',d||''),M(w,$),P(O,'c-t-cn'),P(w,'c-n-t'),P(h,'c-n-c'),P(m,'c-nt'),P(b,'c-n-a'),M(O,w),(f||v)&&M(O,b),M(h,O),M(m,h),M(S,E),M(u,m),(n.thumbnailUrl||s.i)&&M(u,S),M(u,k),c&&D(s.v,i),s.v.prepend(u),s.$=!0,setTimeout((()=>D(s.v,'c-an')),20)}}))},J=(e,t)=>{const o=v[e];o.forEach((n=>{n._||((e,n)=>{u[n]||(u[n]=new IntersectionObserver((e=>{if(w[n])u[n].disconnect();else for(let c=0;c{const i=e[c].target,s=i.dataset.index;L(o[s],t),setTimeout((()=>{A(o[s])}),50*c),u[n].unobserve(i)})(c)}))),u[n].observe(e)})(n.v,e)}))},V=(e,t)=>e in t?e:k(t).length>0?p in t?p:k(t)[0]:void 0,W=(e,t)=>{const{cookie:o}=t;G(o.name)||(e=>{const{hostname:t,protocol:o}=location,n=e.name,c=new Date,i=e.path||'/',s=864e5*(e.expiration||182),r=e.sameSite||'Lax',a=e.domain||t;c.setTime(c.getTime()+s);let f=n+'=1'+(0!==s?`; Expires=${c.toUTCString()}`:'')+`; Path=${i}`+`; SameSite=${r}`;a.indexOf('.')>-1&&(f+=`; Domain=${a}`),'https:'===o&&(f+='; Secure'),l.cookie=f})(o),J(e,t)},q=(e,t)=>{const{cookie:o}=t;G(o.name)&&(e=>{const t=e.name,o=e.path||'/',n=e.domain||location.hostname;l.cookie=`${t}=; Path=${o}; Domain=${n}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`})(o),((e,t)=>{const o=v[e];for(let n=0;n{var n;o[e]._&&(S(t.onReject)?(t.onReject(o[e].D,o[e].v,(()=>F(o[e]))),o[e]._=!1):((n=o[e]).D&&n.D.remove(),n._=!1)),F(o[e])})(n)})(e,t)},z=(e,t,o)=>{S(d)&&d({eventSource:{type:g,service:e,action:t},changedServices:o})},B=e=>{if(e.hasAttribute('data-service')){e.removeAttribute('class'),e.removeAttribute('data-index');for(const t of e.children)t.hasAttribute('data-placeholder')||t.remove()}},K={acceptService:t=>{const o=[];if('all'===t){for(const e of b)w[e]=!1,_.get(e)||(_.set(e,!0),W(e,h[e]),o.push(e));o.length>0&&z(t,n,o)}else b.includes(t)&&(w[t]=!1,_.get(t)||(_.set(t,!0),W(t,h[t]),o.push(t),z(t,n,o)));g=e},rejectService:e=>{const t=[];if('all'===e){for(const e of b)w[e]=!0,q(e,h[e]),_.get(e)&&(_.set(e,!1),t.push(e));t.length>0&&z(e,c,t)}else b.includes(e)&&(w[e]=!0,q(e,h[e]),_.get(e)&&(_.set(e,!1),t.push(e),z(e,c,t)))},childExists:async({parent:e=a,childProperty:t,childSelector:o='iframe',timeout:n=1e3,maxTimeout:c=15e3})=>{let i=1;const s=t?()=>e[t]:()=>e.querySelector(o);return new Promise((e=>{const t=()=>{if(s()||i++*n>c)return e(void 0!==s());setTimeout(t,n)};t()}))},getState:()=>({services:new Map(_),acceptedServices:[..._].filter((([,e])=>!!e)).map((([e])=>e))}),getConfig:()=>f,reset:t=>{if(t)for(const e of b)for(const t of v[e])B(t.v);(()=>{for(const e of b)u[e]?.disconnect(),m[e]?.disconnect(),delete u[e],delete m[e];u={},m={},w={}})(),a=void 0,l=void 0,f=void 0,d=void 0,v={},p='',h={},b=[],_=new Map,g=e,window._imRun=!1},run:e=>{if(window._imRun)return;if(l=document,a=window,f=e,h=f.services,d=f.onChange,b=k(h),0===b.length)return;p=f.currLang;const t=h[b[0]].languages;!0===f.autoLang?p=V(navigator.language.slice(0,2).toLowerCase(),t):x(f.currLang)&&(p=V(f.currLang,t));for(const o of b){const e=h[o],t=e.cookie=e.cookie||{},n=t.name=t.name||`im_${o}`,c=G(n);_.set(o,!!c),v[o]=[];const i=l.querySelectorAll(`div[data-service="${o}"]`),s=i.length;if(0!==s){for(let e=0;eK)})();