@dreher-media/dm-js-lib 0.1.0 → 0.2.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.
package/dist/dm-js-lib.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! dm-js-lib v0.
|
|
2
|
-
!function(){"use strict";function e(e){return new Promise((
|
|
1
|
+
/*! dm-js-lib v0.2.0 */
|
|
2
|
+
!function(){"use strict";function e(e,t="script"){return new Promise((o,n)=>{const a="script"===t?`script[src="${e}"]`:`link[rel="stylesheet"][href="${e}"]`;if(document.querySelector(a))o();else if("script"===t){const t=document.createElement("script");t.src=e,t.async=!0,t.onload=()=>o(),t.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(t)}else if("stylesheet"===t){const t=document.createElement("link");t.rel="stylesheet",t.href=e,t.onload=()=>o(),t.onerror=()=>n(new Error(`Failed to load stylesheet: ${e}`)),document.head.appendChild(t)}else n(new Error(`Unsupported resource type: ${t}`))})}function t(t){return e(t,"script")}function o(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=` ${t} `,e.insertAdjacentElement("afterend",o)}})})}),document.addEventListener("DOMContentLoaded",()=>{const e=e=>{const t=e.dataset.tabTarget;if(t)return t;const o=e.getAttribute("href");return o?.startsWith("#")?o.slice(1):null},t=e=>document.querySelector(`[data-tab-content="${e}"]`);document.querySelectorAll(".tab-link, [data-tab-link]").forEach(o=>{o.addEventListener("click",o=>{o.preventDefault();const n=o.currentTarget,a=n.dataset.tabGroup,r=e(n),l=r?t(r):null;if(a)document.querySelectorAll(`.tab-link[data-tab-group="${a}"], [data-tab-link][data-tab-group="${a}"]`).forEach(e=>{e.classList.remove("active")}),(t=>{const o=[];return document.querySelectorAll(`.tab-link[data-tab-group="${t}"], [data-tab-link][data-tab-group="${t}"]`).forEach(t=>{const n=e(t);n&&o.push(n)}),o})(a).forEach(e=>{const o=t(e);o&&(o.style.display="none",o.classList.remove("active"))});else{const o=n.parentNode;if(o){o.querySelectorAll(".tab-link, [data-tab-link]").forEach(e=>{e.classList.remove("active")});const n=(t=>{const o=[];return t.querySelectorAll(".tab-link, [data-tab-link]").forEach(t=>{const n=e(t);n&&o.push(n)}),o})(o);n.forEach(e=>{const o=t(e);o&&(o.style.display="none",o.classList.remove("active"))})}}n.classList.add("active"),l&&(l.style.display="block",l.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",()=>{let n=[];const a=document.querySelectorAll(".youtube"),r={};let l=!1;const i=document.querySelectorAll("._init-plyr").length>0,d=o("youtube"),s=o("vimeo"),c=o("dailymotion"),u=()=>{void 0!==window.Plyr&&(n=window.Plyr.setup("._init-plyr"),n.forEach(e=>{e.on("play",()=>{p(),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.stop()})}),e.on("pause",()=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.start()})})}))},p=(e=null)=>{n.forEach(e=>{e.pause()});for(const[t,o]of Object.entries(r))e!==t&&("youtube"===o.type?o.player.pauseVideo():("vimeo"===o.type||"dailymotion"===o.type)&&o.player.pause())},y=e=>{p(e),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.stop()})},m=e=>{"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.autoplay.start()})},f=()=>{l||(l=!0,a.forEach(e=>{e.addEventListener("click",()=>{const t=e.querySelector("[data-custom-embed]");t&&(e.innerHTML=t.innerHTML);const o=e,n=`player_${o.dataset.id}`,a=o.dataset.type,l=o.dataset.videoId,i=parseInt(o.dataset.time||"0",10);if(l&&a)if(y(n),"youtube"===a&&window.YT){const e=new window.YT.Player(n,{videoId:l,playerVars:{start:i},events:{onReady:e=>{e.target.playVideo()},onStateChange:e=>{e.data===window.YT.PlayerState.PLAYING?y(n):e.data!==window.YT.PlayerState.PAUSED&&e.data!==window.YT.PlayerState.ENDED||m()}}});r[n]={type:a,player:e}}else if("vimeo"===a&&window.Vimeo){const e=document.getElementById(n);e&&(e.innerHTML="");const t=new window.Vimeo.Player(n,{id:l,autoplay:!0,start:i});t.on("play",()=>y(n)),t.on("pause",()=>m()),r[n]={type:a,player:t}}else"dailymotion"===a&&window.dailymotion&&window.dailymotion.createPlayer(n,{video:l,params:{autoplay:1,start:i,mute:!1}}).then(e=>{e.on("play",()=>y(n)),e.on("pause",()=>m()),e.on("ended",()=>m()),r[n]={type:"dailymotion",player:e}}).catch(e=>{console.error("Error initializing Dailymotion player:",e)})})}))};d&&(window.onYouTubeIframeAPIReady=()=>{f()});const w=[];var h;i&&w.push(window.Plyr&&"function"==typeof window.Plyr.setup?Promise.resolve():Promise.all([(h="https://cdn.plyr.io/3.7.8/plyr.css",e(h,"stylesheet")),t("https://cdn.plyr.io/3.7.8/plyr.polyfilled.js")]).then(()=>{}).catch(e=>{throw console.error("Failed to load Plyr resources:",e),e})),d&&w.push(window.YT&&"function"==typeof window.YT.Player?Promise.resolve():t("https://www.youtube.com/iframe_api").catch(e=>{console.error("Failed to load YouTube API:",e)})),s&&w.push(window.Vimeo&&"function"==typeof window.Vimeo.Player?Promise.resolve():t("https://player.vimeo.com/api/player.js").catch(e=>{console.error("Failed to load Vimeo API:",e)})),c&&w.push(window.dailymotion&&"function"==typeof window.dailymotion.createPlayer?Promise.resolve():t("https://api.dmcdn.net/all.js").catch(e=>{console.error("Failed to load Dailymotion API:",e)})),w.length>0?Promise.all(w).then(()=>{i&&u(),d?setTimeout(()=>{l||f()},1e3):setTimeout(()=>{f()},100)}).catch(e=>{console.error("Error loading video player APIs:",e),i&&void 0!==window.Plyr&&u(),setTimeout(()=>{f()},500)}):(i&&void 0!==window.Plyr&&u(),f()),"undefined"!=typeof videoSwipers&&videoSwipers&&videoSwipers.forEach(e=>{e.on("slideChange",()=>{p()})})}),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,l=new Image;l.onload=()=>{l.naturalWidth>120?o.src=l.src:t(o,n+1)},l.onerror=()=>{t(o,n+1)},l.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,2 +1,2 @@
|
|
|
1
|
-
/*! dm-js-lib/previewDetailSwitcher v0.
|
|
1
|
+
/*! dm-js-lib/previewDetailSwitcher v0.2.0 */
|
|
2
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}({});
|