@dreher-media/dm-js-lib 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,2 @@
1
- !function(){"use strict";!function(){let e=!1;const t=()=>{window.FsCC?(e||(window.FsCC.consentController.on("updateconsents",()=>{t()}),e=!0),document.querySelectorAll("[fs-cc-reject]").forEach(e=>{const t=e.getAttribute("fs-cc-reject");if(!t)return;const o=window.FsCC?.store.consents[t]??!1,n=document.querySelector(`[fs-cc="${t}"]`);o?(e.style.display="none",n&&(n.style.display="block")):(e.style.display="block",n&&(n.style.display="none"))})):setTimeout(t,200)};document.addEventListener("DOMContentLoaded",t)}(),void 0!==window.Webflow&&window.Webflow.push(()=>{document.querySelectorAll(".copyright-year").forEach(e=>{e.textContent=(new Date).getFullYear().toString()});const e=sessionStorage.getItem("selected_lang");if(e){const t=document.querySelector(`.biography-lang-links .tab-link[data-lang="${e}"]`);t?.click?.()}}),function(){const e=e=>{const t=(e||"").replace(/\/+$/,"").replace(/\.html?$/i,"");return""===t?"/":t};window.addEventListener("load",()=>{const t=e(window.location.pathname);document.querySelectorAll("a[href]").forEach(o=>{const n=o.getAttribute("href");if(!n)return;if(n.startsWith("#")||n.toLowerCase().startsWith("javascript:"))return;let a;try{a=new URL(n,window.location.href)}catch{return}if(a.origin!==window.location.origin)return;e(a.pathname)===t&&o.classList.add("w--current")})})}(),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-separator]").forEach(e=>{const t=e.getAttribute("data-separator");if(!t)return;const o=Array.from(e.children);o.forEach((e,n)=>{if(n<o.length-1){const o=document.createElement("span");o.innerHTML=`&nbsp;${t}&nbsp;`,e.insertAdjacentElement("afterend",o)}})})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".tab-link").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.parentNode;if(o){const e=o.querySelector(".tab-link.active");e&&e.classList.remove("active"),t.classList.add("active")}})})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".biography-lang-links .tab-link[data-lang]").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.dataset?.lang;o&&(sessionStorage.setItem("selected_lang",o),document.querySelectorAll(`.biography-text:not(.${o})`).forEach(e=>{e.style.display="none"}),document.querySelectorAll(`.biography-text.${o}`).forEach(e=>{e.style.display="block"}),document.querySelectorAll(`.biography-lang-links .tab-link:not([data-lang="${o}"])`).forEach(e=>{e.classList.remove("active")}),document.querySelectorAll(`.biography-lang-links .tab-link[data-lang="${o}"]`).forEach(e=>{e.classList.add("active")}))})})}),document.addEventListener("DOMContentLoaded",()=>{void 0!==window.Plyr&&window.Plyr.setup("._init-plyr");const e=document.querySelectorAll(".youtube"),t={};let o=!1;const n=(e=null)=>{for(const[o,n]of Object.entries(t))e!==o&&("youtube"===n.type?n.player.pauseVideo():("vimeo"===n.type||"dailymotion"===n.type)&&n.player.pause())},a=e=>{n(e),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.stop()})},r=e=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.start()})},d=()=>{o=!0,e.forEach(e=>{e.addEventListener("click",()=>{const o=e.querySelector("[data-custom-embed]");o&&(e.innerHTML=o.innerHTML);const n=e,d=`player_${n.dataset.id}`,i=n.dataset.type,l=n.dataset.videoId,c=parseInt(n.dataset.time||"0",10);if(l&&i)if(a(d),"youtube"===i&&window.YT){const e=new window.YT.Player(d,{videoId:l,playerVars:{start:c},events:{onReady:e=>{e.target.playVideo()},onStateChange:e=>{e.data===window.YT.PlayerState.PLAYING?a(d):e.data!==window.YT.PlayerState.PAUSED&&e.data!==window.YT.PlayerState.ENDED||r()}}});t[d]={type:i,player:e}}else if("vimeo"===i&&window.Vimeo){const e=document.getElementById(d);e&&(e.innerHTML="");const o=new window.Vimeo.Player(d,{id:l,autoplay:!0,start:c});o.on("play",()=>a(d)),o.on("pause",()=>r()),t[d]={type:i,player:o}}else"dailymotion"===i&&window.dailymotion&&window.dailymotion.createPlayer(d,{video:l,params:{autoplay:1,start:c,mute:!1}}).then(e=>{e.on("play",()=>a(d)),e.on("pause",()=>r()),e.on("ended",()=>r()),t[d]={type:"dailymotion",player:e}}).catch(e=>{console.error("Error initializing Dailymotion player:",e)})})})};window.onYouTubeIframeAPIReady=d,"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.on("slideChange",()=>{n()})}),setTimeout(()=>{o||d()},500)}),document.addEventListener("DOMContentLoaded",()=>{const e=["maxresdefault","sddefault","hqdefault","mqdefault","default"],t=(o,n=0)=>{if(o.naturalWidth>120)return;if(n>=e.length)return;const a=e[n],r=o.src,d=new Image;d.onload=()=>{d.naturalWidth>120?o.src=d.src:t(o,n+1)},d.onerror=()=>{t(o,n+1)},d.src=r.replace(/maxresdefault/,a)};document.querySelectorAll(".youtube img").forEach(e=>{t(e)})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-download-href]").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const o=e.getAttribute("data-download-href"),n=e.getAttribute("data-download-filename");o&&((e,t)=>{const o=document.createElement("a");o.href=e,o.download=t||e.split("/").pop()||"download",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(o,n)})})})}();
1
+ /*! dm-js-lib v0.1.0 */
2
+ !function(){"use strict";function e(e){return new Promise((t,o)=>{if(document.querySelector(`script[src="${e}"]`))return void t();const n=document.createElement("script");n.src=e,n.async=!0,n.onload=()=>t(),n.onerror=()=>o(new Error(`Failed to load script: ${e}`)),document.head.appendChild(n)})}function t(e){const t=document.querySelectorAll(".youtube");return Array.from(t).some(t=>t.dataset.type===e)}!function(){let e=!1;const t=()=>{window.FsCC?(e||(window.FsCC.consentController.on("updateconsents",()=>{t()}),e=!0),document.querySelectorAll("[fs-cc-reject]").forEach(e=>{const t=e.getAttribute("fs-cc-reject");if(!t)return;const o=window.FsCC?.store.consents[t]??!1,n=document.querySelector(`[fs-cc="${t}"]`);o?(e.style.display="none",n&&(n.style.display="block")):(e.style.display="block",n&&(n.style.display="none"))})):setTimeout(t,200)};document.addEventListener("DOMContentLoaded",t)}(),void 0!==window.Webflow&&window.Webflow.push(()=>{document.querySelectorAll(".copyright-year").forEach(e=>{e.textContent=(new Date).getFullYear().toString()});const e=sessionStorage.getItem("selected_lang");if(e){const t=document.querySelector(`.biography-lang-links .tab-link[data-lang="${e}"]`);t?.click?.()}}),function(){const e=e=>{const t=(e||"").replace(/\/+$/,"").replace(/\.html?$/i,"");return""===t?"/":t};window.addEventListener("load",()=>{const t=e(window.location.pathname);document.querySelectorAll("a[href]").forEach(o=>{const n=o.getAttribute("href");if(!n)return;if(n.startsWith("#")||n.toLowerCase().startsWith("javascript:"))return;let a;try{a=new URL(n,window.location.href)}catch{return}if(a.origin!==window.location.origin)return;e(a.pathname)===t&&o.classList.add("w--current")})})}(),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-separator]").forEach(e=>{const t=e.getAttribute("data-separator");if(!t)return;const o=Array.from(e.children);o.forEach((e,n)=>{if(n<o.length-1){const o=document.createElement("span");o.innerHTML=`&nbsp;${t}&nbsp;`,e.insertAdjacentElement("afterend",o)}})})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".tab-link").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.parentNode;if(o){const e=o.querySelector(".tab-link.active");e&&e.classList.remove("active"),t.classList.add("active")}})})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".biography-lang-links .tab-link[data-lang]").forEach(e=>{e.addEventListener("click",e=>{const t=e.currentTarget,o=t.dataset?.lang;o&&(sessionStorage.setItem("selected_lang",o),document.querySelectorAll(`.biography-text:not(.${o})`).forEach(e=>{e.style.display="none"}),document.querySelectorAll(`.biography-text.${o}`).forEach(e=>{e.style.display="block"}),document.querySelectorAll(`.biography-lang-links .tab-link:not([data-lang="${o}"])`).forEach(e=>{e.classList.remove("active")}),document.querySelectorAll(`.biography-lang-links .tab-link[data-lang="${o}"]`).forEach(e=>{e.classList.add("active")}))})})}),document.addEventListener("DOMContentLoaded",()=>{void 0!==window.Plyr&&window.Plyr.setup("._init-plyr");const o=document.querySelectorAll(".youtube"),n={};let a=!1;const r=t("youtube"),i=t("vimeo"),d=t("dailymotion"),l=(e=null)=>{for(const[t,o]of Object.entries(n))e!==t&&("youtube"===o.type?o.player.pauseVideo():("vimeo"===o.type||"dailymotion"===o.type)&&o.player.pause())},c=e=>{l(e),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.stop()})},s=e=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.start()})},u=()=>{a||(a=!0,o.forEach(e=>{e.addEventListener("click",()=>{const t=e.querySelector("[data-custom-embed]");t&&(e.innerHTML=t.innerHTML);const o=e,a=`player_${o.dataset.id}`,r=o.dataset.type,i=o.dataset.videoId,d=parseInt(o.dataset.time||"0",10);if(i&&r)if(c(a),"youtube"===r&&window.YT){const e=new window.YT.Player(a,{videoId:i,playerVars:{start:d},events:{onReady:e=>{e.target.playVideo()},onStateChange:e=>{e.data===window.YT.PlayerState.PLAYING?c(a):e.data!==window.YT.PlayerState.PAUSED&&e.data!==window.YT.PlayerState.ENDED||s()}}});n[a]={type:r,player:e}}else if("vimeo"===r&&window.Vimeo){const e=document.getElementById(a);e&&(e.innerHTML="");const t=new window.Vimeo.Player(a,{id:i,autoplay:!0,start:d});t.on("play",()=>c(a)),t.on("pause",()=>s()),n[a]={type:r,player:t}}else"dailymotion"===r&&window.dailymotion&&window.dailymotion.createPlayer(a,{video:i,params:{autoplay:1,start:d,mute:!1}}).then(e=>{e.on("play",()=>c(a)),e.on("pause",()=>s()),e.on("ended",()=>s()),n[a]={type:"dailymotion",player:e}}).catch(e=>{console.error("Error initializing Dailymotion player:",e)})})}))};r&&(window.onYouTubeIframeAPIReady=()=>{u()});const y=[];r&&y.push(window.YT&&"function"==typeof window.YT.Player?Promise.resolve():e("https://www.youtube.com/iframe_api").catch(e=>{console.error("Failed to load YouTube API:",e)})),i&&y.push(window.Vimeo&&"function"==typeof window.Vimeo.Player?Promise.resolve():e("https://player.vimeo.com/api/player.js").catch(e=>{console.error("Failed to load Vimeo API:",e)})),d&&y.push(window.dailymotion&&"function"==typeof window.dailymotion.createPlayer?Promise.resolve():e("https://api.dmcdn.net/all.js").catch(e=>{console.error("Failed to load Dailymotion API:",e)})),y.length>0?Promise.all(y).then(()=>{r?setTimeout(()=>{a||u()},1e3):setTimeout(()=>{u()},100)}).catch(e=>{console.error("Error loading video player APIs:",e),setTimeout(()=>{u()},500)}):u(),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.on("slideChange",()=>{l()})})}),document.addEventListener("DOMContentLoaded",()=>{const e=["maxresdefault","sddefault","hqdefault","mqdefault","default"],t=(o,n=0)=>{if(o.naturalWidth>120)return;if(n>=e.length)return;const a=e[n],r=o.src,i=new Image;i.onload=()=>{i.naturalWidth>120?o.src=i.src:t(o,n+1)},i.onerror=()=>{t(o,n+1)},i.src=r.replace(/maxresdefault/,a)};document.querySelectorAll(".youtube img").forEach(e=>{t(e)})}),document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-download-href]").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();const o=e.getAttribute("data-download-href"),n=e.getAttribute("data-download-filename");o&&((e,t)=>{const o=document.createElement("a");o.href=e,o.download=t||e.split("/").pop()||"download",document.body.appendChild(o),o.click(),document.body.removeChild(o)})(o,n)})})})}();
@@ -0,0 +1,2 @@
1
+ /*! dm-js-lib/previewDetailSwitcher v0.1.0 */
2
+ var PreviewDetailSwitcher=function(e){"use strict";function t(e={}){const{container:t,itemSelector:r="[data-detail-item]",previewIdAttribute:n="data-preview-id",detailIdAttribute:i="data-detail-id",initialIndex:o=0,displayValue:a="block"}=e,c=(()=>{if(!t)return document;if("string"==typeof t){return document.querySelector(t)||document}return t})(),d=e=>{const t=e.currentTarget;if(!t)return;const o=t.getAttribute(n);if(!o)return;const d=c.querySelector(`${r}[${i}="${o}"]`);if(!d)return;c.querySelectorAll(r).forEach(e=>{e&&(e.style.display="none")}),d.style.display=a},l=()=>{const e=c.querySelectorAll(r);if(0===e.length)return;e.forEach(e=>{e&&(e.style.display="none")});const t=e[o];t?t.style.display=a:e[0]&&(e[0].style.display=a);c.querySelectorAll(`[${n}]`).forEach(e=>{e&&e.addEventListener("click",d)})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",l):l()}return e.initPreviewDetailSwitcher=t,e.initPreviewDetailSwitchers=function(e,r={}){const n=()=>{document.querySelectorAll(e).forEach(e=>{e&&t({...r,container:e})})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n()},e}({});
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@dreher-media/dm-js-lib",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "Centralized JavaScript library for Dreher.Media websites with CDN delivery",
5
5
  "type": "module",
6
6
  "main": "dist/dm-js-lib.min.js",
7
7
  "files": [
8
8
  "dist/dm-js-lib.min.js",
9
+ "dist/standalone",
9
10
  "README.md"
10
11
  ],
11
12
  "scripts": {
@@ -22,7 +23,7 @@
22
23
  "javascript",
23
24
  "typescript"
24
25
  ],
25
- "author": "",
26
+ "author": "Tobias Laufersweiler <tobias@dreher-media.de>",
26
27
  "license": "MIT",
27
28
  "devDependencies": {
28
29
  "@rollup/plugin-terser": "^0.4.4",