@kendawson-online/vantl 2.0.6 → 2.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.
- package/README.md +48 -24
- package/dist/images/alert.svg +50 -0
- package/dist/images/arrow-left.svg +1 -0
- package/dist/images/arrow-right.svg +1 -0
- package/dist/images/missing-image.svg +29 -0
- package/dist/timeline.min.css +1 -1
- package/dist/timeline.min.css.map +1 -1
- package/dist/timeline.min.js +1 -1
- package/dist/timeline.min.js.map +1 -1
- package/package.json +27 -13
- package/src/css/timeline.css +895 -175
- package/src/images/alert.svg +0 -0
- package/src/images/missing-image.svg +0 -0
- package/src/images/spinner.gif +0 -0
package/dist/timeline.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Timeline=function(e){"use strict";const t={count:0,startTime:0,removeTimer:null,overlayEl:null},i={modal:null,overlay:null},n={};function o(){if(i.modal)return;i.overlay=document.createElement("div"),i.overlay.className="timeline-modal-overlay",i.overlay.addEventListener("click",a),i.modal=document.createElement("div"),i.modal.className="timeline-modal",i.modal.innerHTML='\n <button class="timeline-modal__close" aria-label="Close modal"></button>\n <div class="timeline-modal__content">\n <img class="timeline-modal__image" src="" alt="" style="display: none;">\n <h2 class="timeline-modal__title"></h2>\n <div class="timeline-modal__text"></div>\n <hr class="timeline-modal__divider">\n <button class="timeline-modal__close-bottom">Close</button>\n </div>\n ';const e=i.modal.querySelector(".timeline-modal__close"),t=i.modal.querySelector(".timeline-modal__close-bottom");e.addEventListener("click",a),t.addEventListener("click",a),i.modal.addEventListener("click",function(e){e.stopPropagation()}),document.body.appendChild(i.overlay),document.body.appendChild(i.modal),document.addEventListener("keydown",function(e){"Escape"===e.key&&i.modal.classList.contains("timeline-modal-show")&&a()})}function l(e){i.modal||o();const t=e.getAttribute("data-modal-title"),n=e.getAttribute("data-modal-content"),l=e.getAttribute("data-modal-image"),a=e.getAttribute("data-modal-html"),r=i.modal.querySelector(".timeline-modal__title"),s=i.modal.querySelector(".timeline-modal__text"),d=i.modal.querySelector(".timeline-modal__image");r.textContent=t||"",l?(d.src=l,d.alt=t||"",d.style.display="block"):d.style.display="none",s.innerHTML=a||(n?"<p>"+n.replace(/\n/g,"</p><p>")+"</p>":""),setTimeout(function(){i.modal.classList.add("timeline-modal-show"),i.overlay.classList.add("timeline-modal-show"),document.body.style.overflow="hidden"},10)}function a(){i.modal&&(i.modal.classList.remove("timeline-modal-show"),i.overlay.classList.remove("timeline-modal-show"),document.body.style.overflow="")}function r(e){const t=new URLSearchParams(window.location.search),i=t.get("timeline"),n=t.get("id");if(!n)return;let o;if(o=i?document.getElementById(i):document.querySelector(e),!o)return void console.warn("Timeline not found for deep linking:",i||e);o.scrollIntoView({behavior:"smooth",block:"start"});const l=o.querySelector('[data-node-id="'+n+'"]');l&&setTimeout(function(){l.classList.add("timeline__item--active");const e=Array.from(l.parentNode.children).indexOf(l);s(o,e)},500)}function s(e,t){if(!e)return;const i=e.id||e.getAttribute("data-timeline-id");if(!i)return void console.warn("Cannot navigate: timeline container has no ID");const o=n[i];o?e.classList.contains("timeline--horizontal")&&o.setCurrentIndex&&o.updatePosition&&(o.setCurrentIndex(t),o.updatePosition()):console.warn("Timeline not found in registry:",i)}const d=function(){if("undefined"!=typeof window&&window.TimelineConfig&&window.TimelineConfig.basePath)return window.TimelineConfig.basePath;const e=document.getElementsByTagName("script");for(let t=0;t<e.length;t++){const i=e[t].src||"";if(!i)continue;const n=i.substring(0,i.lastIndexOf("/"));if(-1!==i.indexOf("timeline.min.js"))return n.replace("/dist","/src/images");if(-1!==i.indexOf("timeline.js"))return n.replace("/js","/images")}return"../src/images"}();function m(){if(t.count+=1,1!==t.count)return;t.startTime=Date.now(),t.removeTimer&&(clearTimeout(t.removeTimer),t.removeTimer=null);const e=document.createElement("div");e.className="timeline__loader-overlay";const i=document.createElement("div");i.className="timeline__loader";const n=document.createElement("img");n.src=d+"/spinner.gif",n.alt="Loading...",n.title="Loading...",n.className="timeline__loader-spinner",n.width=120,n.style.height="auto",i.appendChild(n),e.appendChild(i),document.body.appendChild(e),t.overlayEl=e}function c(){if(t.count<=0)return;if(t.count-=1,t.count>0)return;const e=Date.now()-t.startTime,i=Math.max(0,1300-e),n=function(){t.overlayEl&&(t.overlayEl.remove(),t.overlayEl=null),t.removeTimer=null};t.removeTimer&&(clearTimeout(t.removeTimer),t.removeTimer=null),i>0?t.removeTimer=setTimeout(n,i):n()}function u(e,t,i){if(!e)return;const n={"json-load":{title:"Timeline Data Could Not Be Loaded",message:"The timeline data failed to load. This could be due to a network error or an incorrect file path.",solution:"Please check that the data-json-config path is correct and the file is accessible."},"json-parse":{title:"Invalid Timeline Data",message:"The timeline data file exists but contains invalid JSON.",solution:"Please validate your JSON using a tool like jsonlint.com and ensure it follows the correct schema."},"missing-element":{title:"Timeline Element Not Found",message:"The required timeline container element could not be found on the page.",solution:'Ensure your HTML includes a container with the class "timeline" and the correct selector.'},"invalid-config":{title:"Invalid Configuration",message:"One or more timeline configuration options are invalid.",solution:"Check your data attributes or JavaScript options and ensure they match the expected format."}}[t]||{title:"Timeline Error",message:"An unexpected error occurred while initializing the timeline.",solution:"Please check the browser console for more details."};c(),e.innerHTML="";const o=document.createElement("div");o.className="timeline__error";const l=document.createElement("img");l.src=d+"/alert.svg",l.alt="Error",l.className="timeline__error-icon",l.width=200,l.style.height="auto";const a=document.createElement("h2");a.className="timeline__error-title",a.textContent=n.title;const r=document.createElement("p");r.className="timeline__error-message",r.textContent=n.message;const s=document.createElement("p");if(s.className="timeline__error-solution",s.innerHTML="<strong>Solution:</strong> "+n.solution,i){const e=document.createElement("p");e.className="timeline__error-details",e.innerHTML="<strong>Details:</strong> "+i,o.appendChild(e)}o.appendChild(l),o.appendChild(a),o.appendChild(r),o.appendChild(s),e.appendChild(o),console.error("Timeline Error ["+t+"]:",n.message,i||"")}function h(e){let t;if(!e||"string"!=typeof e)return 128;if(e.startsWith("#")){let i=e.substring(1);3===i.length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);t=[parseInt(i.substring(0,2),16),parseInt(i.substring(2,4),16),parseInt(i.substring(4,6),16)]}else{if(!e.startsWith("rgb"))return 128;{const i=e.match(/\d+/g);t=i?i.map(Number):[128,128,128]}}return(299*t[0]+587*t[1]+114*t[2])/1e3}function f(e,t){let i=t.nodeColor||null,n=t.lineColor||null;const o=t.navColor||null;if(i&&!n&&(n=i),n&&!i&&(i=n),i&&e.style.setProperty("--timeline-node-color",i),n&&e.style.setProperty("--timeline-line-color",n),o){e.style.setProperty("--timeline-nav-color",o),e.style.setProperty("--timeline-nav-border",h(o)>128?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.3)");const t=h(o)>128?"#333":"#fff";e.style.setProperty("--timeline-arrow-color",t),e.setAttribute("data-arrow-color",t)}}function g(e,t){return"left"===e?'<svg xmlns="http://www.w3.org/2000/svg" width="7.8" height="14" style="display:block;margin:auto;"><path fill="none" stroke="'+t+'" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M6.8 1L1 7l5.8 6"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="7.8" height="14" style="display:block;margin:auto;"><path fill="none" stroke="'+t+'" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M1 1l5.8 6L1 13"/></svg>'}function v(e,t){const i=[],o="Timeline:";let a,r=window.innerWidth,s=0;m();let d=!0;const h={minWidth:{type:"integer",defaultValue:600},maxWidth:{type:"integer",defaultValue:600},horizontalStartPosition:{type:"string",acceptedValues:["bottom","top"],defaultValue:"top"},mode:{type:"string",acceptedValues:["horizontal","vertical"],defaultValue:"vertical"},moveItems:{type:"integer",defaultValue:1},rtlMode:{type:"boolean",acceptedValues:[!0,!1],defaultValue:!1},startIndex:{type:"integer",defaultValue:0},verticalStartPosition:{type:"string",acceptedValues:["left","right"],defaultValue:"left"},verticalTrigger:{type:"string",defaultValue:"15%"},visibleItems:{type:"integer",defaultValue:3}};function v(e,t,i){t.classList.add(i),e.parentNode.insertBefore(t,e),t.appendChild(e)}function p(e,t){const i=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=h.verticalTrigger.defaultValue.match(/(\d*\.?\d*)(.*)/);let l=t.unit,a=t.value,r=n;return"px"===l&&a>=n&&(console.warn('The value entered for the setting "verticalTrigger" is larger than the window height. The default value will be used instead.'),[,a,l]=o),"px"===l?r=parseInt(r-a,10):"%"===l&&(r=parseInt(r*((100-a)/100),10)),i.top<=r&&i.left<=(window.innerWidth||document.documentElement.clientWidth)&&i.top+i.height>=0&&i.left+i.width>=0}function w(e,t){e.style.webkitTransform=t,e.style.msTransform=t,e.style.transform=t}function b(e){const t=`translate3d(-${e.items[s].offsetLeft}px, 0, 0)`;w(e.scroller,t)}function y(e){s=e.settings.rtlMode?e.items.length>e.settings.visibleItems?e.items.length-e.settings.visibleItems:0:e.settings.startIndex,e.timelineEl.classList.add("timeline--horizontal"),function(e){window.innerWidth>e.settings.minWidth&&(e.itemWidth=200,e.items.forEach(t=>{t.style.width=`${e.itemWidth}px`}),e.scrollerWidth=e.itemWidth*e.items.length,e.scroller.style.width=`${e.scrollerWidth}px`,function(){let t=0,i=0;e.items.forEach((e,n)=>{e.style.height="auto";const o=e.offsetHeight;n%2==0?i=o>i?o:i:t=o>t?o:t});const n=`translateY(${i}px)`;e.items.forEach((o,l)=>{l%2==0?(o.style.height=`${i}px`,"bottom"===e.settings.horizontalStartPosition?(o.classList.add("timeline__item--bottom"),w(o,n)):o.classList.add("timeline__item--top")):(o.style.height=`${t}px`,"bottom"!==e.settings.horizontalStartPosition?(o.classList.add("timeline__item--bottom"),w(o,n)):o.classList.add("timeline__item--top"))}),e.scroller.style.height=`${i+t}px`}())}(e),b(e),function(e){const t=e.wrap.offsetWidth,i=Math.floor(t/e.itemWidth);if(e.items.length>i){const t=document.createElement("button"),n=document.createElement("button"),o=e.items[0].offsetHeight;t.className="timeline-nav-button timeline-nav-button--prev",n.className="timeline-nav-button timeline-nav-button--next",t.textContent="Previous",n.textContent="Next",t.style.top=`${o}px`,n.style.top=`${o}px`;const l=e.timelineEl.getAttribute("data-arrow-color")||"#333";t.innerHTML=g("left",l),n.innerHTML=g("right",l);const a=Math.max(0,e.items.length-i);0===s?t.disabled=!0:s>=a&&(n.disabled=!0),e.timelineEl.appendChild(t),e.timelineEl.appendChild(n)}}(e),function(e){const t=e.timelineEl.querySelector(".timeline-divider");t&&e.timelineEl.removeChild(t);const i=e.items[0].offsetHeight,n=document.createElement("span");n.className="timeline-divider",n.style.top=`${i}px`,e.timelineEl.appendChild(n)}(e),function(e){const t=e.timelineEl.querySelectorAll(".timeline-nav-button"),i=e.timelineEl.querySelector(".timeline-nav-button--prev"),n=e.timelineEl.querySelector(".timeline-nav-button--next"),o=e.wrap.offsetWidth,l=Math.floor(o/e.itemWidth),a=Math.max(0,e.items.length-l),r=parseInt(e.settings.moveItems,10),d=function(t){t.preventDefault(),t.stopPropagation(),this.disabled||(s=this.classList.contains("timeline-nav-button--next")?s+=r:s-=r,0===s||s<0?(s=0,i.disabled=!0,n.disabled=!1):s===a||s>a?(s=a,i.disabled=!1,n.disabled=!0):(i.disabled=!1,n.disabled=!1),b(e))};Array.from(t).forEach(t=>{t.addEventListener("click",d),e.listeners.push({element:t,type:"click",handler:d})})}(e);const t=e.timelineEl.id||e.timelineEl.getAttribute("data-timeline-id");t&&(n[t]={setCurrentIndex:function(t){const i=e.wrap.offsetWidth,n=Math.floor(i/e.itemWidth),o=Math.max(0,e.items.length-n);s=Math.max(0,Math.min(t,o))},updatePosition:function(){b(e);const t=e.timelineEl.querySelector(".timeline-nav-button--prev"),i=e.timelineEl.querySelector(".timeline-nav-button--next");if(t&&i){const n=e.wrap.offsetWidth,o=Math.floor(n/e.itemWidth),l=Math.max(0,e.items.length-o);t.disabled=0===s,i.disabled=s>=l}}})}function E(){i.forEach(e=>{e.timelineEl.style.opacity=0,e.timelineEl.classList.contains("timeline--loaded")||e.items.forEach(e=>{v(e.querySelector(".timeline__content"),document.createElement("div"),"timeline__content__wrap"),v(e.querySelector(".timeline__content__wrap"),document.createElement("div"),"timeline__item__inner")}),function(e){e.listeners&&e.listeners.length>0&&(e.listeners.forEach(({element:e,type:t,handler:i})=>{e.removeEventListener(t,i)}),e.listeners=[]),e.observer&&(e.observer.disconnect(),e.observer=null),e.timelineEl.classList.remove("timeline--horizontal","timeline--mobile"),e.scroller.removeAttribute("style"),e.items.forEach(e=>{e.removeAttribute("style"),e.classList.remove("animated","fadeIn","timeline__item--left","timeline__item--right")});const t=e.timelineEl.querySelectorAll(".timeline-nav-button");Array.from(t).forEach(e=>{e.parentNode.removeChild(e)})}(e),window.innerWidth<=e.settings.minWidth&&e.timelineEl.classList.add("timeline--mobile");let t=!1;("horizontal"===e.settings.mode&&window.innerWidth>e.settings.minWidth||"vertical"===e.settings.mode&&window.innerWidth>e.settings.maxWidth)&&(t=!0),t?y(e):function(e){let t=0;e.items.forEach((i,n)=>{i.classList.remove("animated","fadeIn"),!p(i,e.settings.verticalTrigger)&&n>0?i.classList.add("animated"):t=n,n%2==("left"===e.settings.verticalStartPosition?1:0)&&window.innerWidth>e.settings.minWidth?i.classList.add("timeline__item--right"):i.classList.add("timeline__item--left")});for(let i=0;i<t;i+=1)e.items[i].classList.remove("animated","fadeIn");if("IntersectionObserver"in window){const t={rootMargin:"%"===e.settings.verticalTrigger.unit?`${e.settings.verticalTrigger.value}%`:`${e.settings.verticalTrigger.value}px`,threshold:.01},i=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.target.classList.add("fadeIn")})},t);e.items.forEach(e=>{e.classList.contains("animated")&&i.observe(e)}),e.observer=i}else{const t=()=>{e.items.forEach(t=>{p(t,e.settings.verticalTrigger)&&t.classList.add("fadeIn")})};window.addEventListener("scroll",t),e.listeners.push({element:window,type:"scroll",handler:t})}}(e),e.timelineEl.classList.add("timeline--loaded")}),setTimeout(()=>{i.forEach(e=>{e.timelineEl.style.opacity=1})},500),d&&(c(),d=!1)}e.length&&Array.from(e).forEach(function(e){const n=e.id?`#${e.id}`:`.${e.className}`,a="could not be found as a direct descendant of",r=e.dataset;let s,d,m;const c={};try{if(s=e.querySelector(".timeline__wrap"),!s)throw new Error(`${o} .timeline__wrap ${a} ${n}`);if(d=s.querySelector(".timeline__items"),!d)throw new Error(`${o} .timeline__items ${a} .timeline__wrap`);m=[].slice.call(d.children,0)}catch(t){return console.warn(t.message),u(e,"missing-element",t.message),!1}Object.keys(h).forEach(e=>{if(c[e]=h[e].defaultValue,"minWidth"===e){let e;void 0!==r.minWidth&&(e=r.minWidth),void 0!==r.minwidth&&(e=r.minwidth),void 0!==r.forceVerticalMode&&(e=r.forceVerticalMode),void 0!==r.forceverticalmode&&(e=r.forceverticalmode),void 0===e&&t&&(void 0!==t.minWidth?e=t.minWidth:void 0!==t.forceVerticalMode&&(e=t.forceVerticalMode)),void 0!==e&&(c.minWidth=e)}else if("maxWidth"===e){let e;void 0!==r.maxWidth&&(e=r.maxWidth),void 0!==r.maxwidth&&(e=r.maxwidth),void 0===e&&t&&void 0!==t.maxWidth&&(e=t.maxWidth),void 0!==e&&(c.maxWidth=e)}else r[e]?c[e]=r[e]:t&&void 0!==t[e]&&(c[e]=t[e]);var i,n;"integer"===h[e].type?c[e]&&(n=e,"number"==typeof(i=c[e])||i%1==0||(console.warn(`${o} The value "${i}" entered for the setting "${n}" is not an integer.`),0))||(c[e]=h[e].defaultValue):"string"===h[e].type&&h[e].acceptedValues&&-1===h[e].acceptedValues.indexOf(c[e])&&(console.warn(`${o} The value "${c[e]}" entered for the setting "${e}" was not recognised.`),c[e]=h[e].defaultValue)}),function(){const i=e.dataset,n=function(e){return void 0!==i[e]?i[e]:void 0!==i[e&&e.toLowerCase()]?i[e.toLowerCase()]:void 0};let o=n("nodeColor"),l=n("lineColor"),a=n("navColor");t&&(void 0!==t.nodeColor&&(o=t.nodeColor),void 0!==t.lineColor&&(l=t.lineColor),void 0!==t.navColor&&(a=t.navColor)),(o||l||a)&&f(e,{nodeColor:o,lineColor:l,navColor:a})}();const g=h.verticalTrigger.defaultValue.match(/(\d*\.?\d*)(.*)/),v=c.verticalTrigger.match(/(\d*\.?\d*)(.*)/);let[,p,w]=v,b=!0;p||(console.warn(`${o} No numercial value entered for the 'verticalTrigger' setting.`),b=!1),"px"!==w&&"%"!==w&&(console.warn(`${o} The setting 'verticalTrigger' must be a percentage or pixel value.`),b=!1),"%"===w&&(p>100||p<0)?(console.warn(`${o} The 'verticalTrigger' setting value must be between 0 and 100 if using a percentage value.`),b=!1):"px"===w&&p<0&&(console.warn(`${o} The 'verticalTrigger' setting value must be above 0 if using a pixel value.`),b=!1),!1===b&&([,p,w]=g),c.verticalTrigger={unit:w,value:p},c.moveItems>c.visibleItems&&(console.warn(`${o} The value of "moveItems" (${c.moveItems}) is larger than the number of "visibleItems" (${c.visibleItems}). The value of "visibleItems" has been used instead.`),c.moveItems=c.visibleItems),c.startIndex>m.length-c.visibleItems&&m.length>c.visibleItems?(console.warn(`${o} The 'startIndex' setting must be between 0 and ${m.length-c.visibleItems} for this timeline. The value of ${m.length-c.visibleItems} has been used instead.`),c.startIndex=m.length-c.visibleItems):m.length<=c.visibleItems?(console.warn(`${o} The number of items in the timeline must exceed the number of visible items to use the 'startIndex' option.`),c.startIndex=0):c.startIndex<0&&(console.warn(`${o} The 'startIndex' setting must be between 0 and ${m.length-c.visibleItems} for this timeline. The value of 0 has been used instead.`),c.startIndex=0),function(e,t){t&&t.length&&t.forEach(function(e){"1"!==e.getAttribute("data-modal-bound")&&(function(e){if(!e)return;const t=e.querySelector(".timeline__content")||e;if(!e.hasAttribute("data-modal-title")){const i=t.querySelector("h1,h2,h3,h4,h5,h6");i&&i.textContent&&e.setAttribute("data-modal-title",i.textContent.trim())}if(!e.hasAttribute("data-modal-content")){const i=t.querySelector("p");i&&i.textContent&&e.setAttribute("data-modal-content",i.textContent.trim())}if(!e.hasAttribute("data-modal-image")){const i=t.querySelector("img");i&&i.getAttribute("src")&&e.setAttribute("data-modal-image",i.getAttribute("src"))}}(e),(e.hasAttribute("data-modal-title")||e.hasAttribute("data-modal-content")||e.hasAttribute("data-modal-image")||e.hasAttribute("data-modal-html"))&&(e.addEventListener("click",function(t){t.preventDefault(),l(e)}),e.setAttribute("data-modal-bound","1")))})}(0,m),e.id||e.setAttribute("data-timeline-id","timeline-"+Date.now()+"-"+Math.random().toString(36).substr(2,9)),i.push({timelineEl:e,wrap:s,scroller:d,items:m,settings:c,listeners:[]})}),E(),window.addEventListener("resize",()=>{clearTimeout(a),a=setTimeout(()=>{const e=window.innerWidth;e!==r&&(E(),r=e)},250)})}function p(e,t,i){const n=document.querySelector(e);if(!n)return;let o=n.querySelector(".timeline__items");if(o)o.innerHTML="";else{const e=document.createElement("div");e.className="timeline__wrap",o=document.createElement("div"),o.className="timeline__items",e.appendChild(o),n.appendChild(e)}if(i&&(function(e,t){t.layoutMode&&e.setAttribute("data-mode",t.layoutMode),void 0!==t.visibleItems&&e.setAttribute("data-visible-items",t.visibleItems),void 0!==t.minWidth&&(e.setAttribute("data-min-width",t.minWidth),e.setAttribute("data-force-vertical-mode",t.minWidth)),void 0!==t.maxWidth&&e.setAttribute("data-max-width",t.maxWidth)}(n,i),f(n,i),i.timelineName&&""!==i.timelineName.trim())){const e=n.previousElementSibling;if(e&&e.classList.contains("timeline__heading"))e.textContent=i.timelineName;else{const e=document.createElement("h1");e.className="timeline__heading",e.textContent=i.timelineName,n.parentNode.insertBefore(e,n)}n.setAttribute("data-timeline-name",i.timelineName)}return t.forEach(function(e){o.appendChild(function(e){const t=document.createElement("div");t.className="timeline__item",e.id&&t.setAttribute("data-node-id",e.id),t.setAttribute("data-modal-title",e.title||""),t.setAttribute("data-modal-content",e.content||""),t.setAttribute("data-modal-image",e.image||""),e.html&&t.setAttribute("data-modal-html",e.html);const i=document.createElement("div");if(i.className="timeline__content",e.image){const t=document.createElement("img");t.src=e.image,t.className="timeline__image",t.alt=e.title||"",t.onerror=function(){console.error('Timeline: The image "'+e.image+'" could not be loaded. Please check the path.'),this.src=d+"/missing-image.svg",this.alt="Image not found",this.title="Original image: "+e.image},i.appendChild(t)}const n=document.createElement("div");if(e.title){const t=document.createElement("h3");t.textContent=e.title,n.appendChild(t)}if(e.content){const t=document.createElement("p");let i=e.content;i.length>105&&(i=i.substring(0,105)+"..."),t.innerHTML=i,n.appendChild(t)}if(e.html){const t=document.createElement("div");t.innerHTML=e.html,n.appendChild(t)}return i.appendChild(n),t.appendChild(i),t.addEventListener("click",function(e){e.preventDefault(),"function"==typeof window.openTimelineModal&&window.openTimelineModal(t)}),t.setAttribute("data-modal-bound","1"),t}(e))}),n}function w(e,t,i){const n=p(e,t,i);n&&v([n],i)}function b(e,t){const i=document.querySelector(t);if(!i)return void console.error("Timeline: Container not found:",t);m();const n=i?i.id:null,o=n?"vjs_"+n:null;if(o&&"undefined"!=typeof Storage)try{const i=localStorage.getItem(o);if(i){const l=JSON.parse(i);return void fetch(e).then(function(t){if(!t.ok)throw new Error("Failed to load "+e+" ("+t.status+")");return t.json()}).then(function(e){e.lastupdated&&l.lastupdated&&e.lastupdated===l.lastupdated?(console.log("Using cached timeline data for",n),y(l,t)):(console.log("Updating cached timeline data for",n),localStorage.setItem(o,JSON.stringify(e)),y(e,t))}).catch(function(e){console.warn("Failed to fetch fresh data, using cache:",e),y(l,t)})}}catch(e){console.warn("Error reading from localStorage:",e)}fetch(e).then(function(t){if(!t.ok)throw new Error("Failed to load "+e+" ("+t.status+")");return t.json()}).then(function(e){if(o&&"undefined"!=typeof Storage)try{localStorage.setItem(o,JSON.stringify(e)),console.log("Cached timeline data for",n)}catch(e){console.warn("Failed to cache timeline data:",e)}y(e,t)}).catch(function(e){console.error("Error loading timeline JSON:",e),u(i,"json-load",e.message)})}function y(e,t){const i=document.querySelector(t);if(!i)return void console.error("Timeline: Container not found:",t);let n=null,o=[];try{if(e.nodes&&Array.isArray(e.nodes))o=e.nodes,n={timelineName:e.timelineName,layoutMode:e.layoutMode,visibleItems:e.visibleItems,minWidth:e.minWidth,maxWidth:e.maxWidth,nodeColor:e.nodeColor,lineColor:e.lineColor,navColor:e.navColor,lastupdated:e.lastupdated};else{if(!Array.isArray(e))throw new Error('Invalid JSON format. Expected object with "nodes" array or simple array.');o=e}if(0===o.length)throw new Error("No timeline items found in data.");p(t,o,n);try{v(document.querySelectorAll(t)),r(t),c()}catch(e){console.error("Error initializing timeline:",e);const i=document.querySelector(t);i&&u(i,"invalid-config",e.message),c()}}catch(e){console.error("Error processing timeline data:",e),u(i,"json-parse",e.message),c()}}function E(e){if("undefined"!=typeof Storage)if(e){const t="vjs_"+e;localStorage.removeItem(t),console.log("Cleared cache for timeline:",e)}else{const e=Object.keys(localStorage);let t=0;e.forEach(function(e){e.startsWith("vjs_")&&(localStorage.removeItem(e),t++)}),console.log("Cleared",t,"timeline cache(s)")}else console.warn("localStorage not supported")}return"undefined"!=typeof window&&(window.timeline=v,window.timelineFromData=w,window.renderTimelineFromData=p,window.processTimelineData=y,window.loadDataFromJson=b,window.clearTimelineCache=E,window.createTimelineModal=o,window.openTimelineModal=l,window.closeTimelineModal=a,window.handleTimelineDeepLinking=r,window.navigateTimelineToNodeIndex=s),document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-json-config]").forEach(function(e){const t=e.getAttribute("data-json-config");if(!t)return;const i=(e.className||"").split(" ")[0],n=e.id?"#"+e.id:i?"."+i:null;n&&b(t,n)})}),"undefined"!=typeof window&&window.jQuery&&(window.jQuery.fn.timeline=function(e){return v(this,e),this}),e.clearTimelineCache=E,e.closeTimelineModal=a,e.createTimelineModal=o,e.handleDeepLinking=r,e.loadDataFromJson=b,e.navigateToNodeIndex=s,e.openTimelineModal=l,e.processTimelineData=y,e.renderTimelineFromData=p,e.timeline=v,e.timelineFromData=w,e}({});
|
|
1
|
+
var Timeline=function(e){"use strict";const t={modal:null,overlay:null},i={};let n=null,o=null;function a(e){const t=e?e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'):[];return Array.from(t).filter(e=>!e.hasAttribute("disabled"))}function r(e){if(!t.modal||"Tab"!==e.key)return;const i=a(t.modal);if(0===i.length)return;const n=i[0],o=i[i.length-1],r=document.activeElement;e.shiftKey?r!==n&&t.modal.contains(r)||(e.preventDefault(),o.focus()):r!==o&&t.modal.contains(r)||(e.preventDefault(),n.focus())}function l(){if(t.modal)return;t.overlay=document.createElement("div"),t.overlay.className="timeline-modal-overlay",t.overlay.addEventListener("click",d),t.modal=document.createElement("div"),t.modal.className="timeline-modal",t.modal.setAttribute("role","dialog"),t.modal.setAttribute("aria-modal","true");const e="timeline-modal-title";t.modal.setAttribute("aria-labelledby",e),t.modal.innerHTML=`\n <button class="timeline-modal__close" aria-label="Close modal" type="button"></button>\n <div class="timeline-modal__content">\n <img class="timeline-modal__image" src="" alt="" loading="lazy" style="display: none;">\n <h2 class="timeline-modal__title" id="${e}"></h2>\n <div class="timeline-modal__text"></div>\n </div>\n <div class="timeline-modal__footer">\n <button class="timeline-modal__close-bottom" type="button">Close</button>\n </div>\n `;const i=t.modal.querySelector(".timeline-modal__close"),n=t.modal.querySelector(".timeline-modal__close-bottom");i.addEventListener("click",d),n.addEventListener("click",d),t.modal.addEventListener("keydown",r),t.modal.addEventListener("click",function(e){e.stopPropagation()}),document.body.appendChild(t.overlay),document.body.appendChild(t.modal),o=function(e){"Escape"===e.key&&t.modal.classList.contains("timeline-modal-show")&&d()},document.addEventListener("keydown",o)}function s(e){t.modal||l(),n=document.activeElement;const i=e.getAttribute("data-modal-title"),o=e.getAttribute("data-modal-content"),r=e.getAttribute("data-modal-image"),s=e.getAttribute("data-modal-html"),d=t.modal.querySelector(".timeline-modal__title"),c=t.modal.querySelector(".timeline-modal__text"),m=t.modal.querySelector(".timeline-modal__image");if(d.textContent=i||"",r?(m.src=r,m.alt=i||"",m.style.display="block"):m.style.display="none",s)c.innerHTML=s;else{const t=e.querySelector(".timeline__modal-content");t&&t.innerHTML&&""!==t.innerHTML.trim()?c.innerHTML=t.innerHTML:c.innerHTML=o?"<p>"+o.replace(/\n/g,"</p><p>")+"</p>":""}setTimeout(function(){if(t.modal&&t.overlay){t.modal.classList.add("timeline-modal-show"),t.overlay.classList.add("timeline-modal-show"),document.body.style.overflow="hidden";const e=a(t.modal)[0];e&&e.focus()}},10)}function d(){t.modal&&(t.modal.classList.remove("timeline-modal-show"),t.overlay.classList.remove("timeline-modal-show"),document.body.style.overflow="",n&&"function"==typeof n.focus&&n.focus())}function c(){if(o){try{document.removeEventListener("keydown",o)}catch(e){}o=null}if(t.modal){try{t.modal.removeEventListener("keydown",r)}catch(e){}try{t.modal.parentNode&&t.modal.parentNode.removeChild(t.modal)}catch(e){}}if(t.overlay)try{t.overlay.parentNode&&t.overlay.parentNode.removeChild(t.overlay)}catch(e){}t.modal=null,t.overlay=null,document.body.style.overflow="",n=null}function m(e){const t=new URLSearchParams(window.location.search),i=t.get("timeline"),n=t.get("id");if(!n)return;let o;if(o=i?document.getElementById(i):document.querySelector(e),!o)return void console.warn("Timeline not found for deep linking:",i||e);o.classList.contains("timeline--horizontal")&&o.scrollIntoView({behavior:"smooth",block:"start"});let a=o.querySelector('[data-node-id="'+n+'"]');if(!a)try{const e=document.getElementById(n);e&&o.contains(e)&&(a=e)}catch(e){}a&&setTimeout(function(){o.querySelectorAll(".timeline__item--active").forEach(e=>e.classList.remove("timeline__item--active")),a.classList.add("timeline__item--active");const e=Array.from(a.parentNode.children||[]).indexOf(a);if(o.classList.contains("timeline--horizontal"))u(o,e);else{try{a.id||(a.id=String(n))}catch(e){}try{window.location&&window.location.hash!=="#"+String(n)&&(window.location.hash=String(n))}catch(e){}try{a.scrollIntoView({behavior:"auto",block:"start"})}catch(e){}}},0)}function u(e,t){if(!e)return;const n=e.id||e.getAttribute("data-timeline-id");if(!n)return void console.warn("Cannot navigate: timeline container has no ID");const o=i[n];o?e.classList.contains("timeline--horizontal")&&o.setCurrentIndex&&o.updatePosition&&(o.setCurrentIndex(t),o.updatePosition()):console.warn("Timeline not found in registry:",n)}const h=function(){if("undefined"!=typeof window&&window.TimelineConfig&&window.TimelineConfig.basePath)return window.TimelineConfig.basePath;const e=document.getElementsByTagName("script");for(let t=0;t<e.length;t++){const i=e[t].src||"";if(!i)continue;const n=i.substring(0,i.lastIndexOf("/"));if(-1!==i.indexOf("timeline.min.js"))return n+"/images";if(-1!==i.indexOf("timeline.js"))return n.replace("/js","/images")}return"../dist/images"}();function f(e,t,i){if(!e)return;const n={"json-load":{title:"Timeline Data Could Not Be Loaded",message:"The timeline data failed to load. This could be due to a network error or an incorrect file path.",solution:"Please check that the data-json-config path is correct and the file is accessible."},"load-failed":{title:"Timeline Data Could Not Be Loaded",message:"The timeline data failed to load. This could be due to a network error or an incorrect file path.",solution:"Please check that the data-json-config path is correct and the file is accessible."},"json-parse":{title:"Invalid Timeline Data",message:"The timeline data file exists but contains invalid JSON.",solution:"Please validate your JSON using a tool like jsonlint.com and ensure it follows the correct schema."},"missing-element":{title:"Timeline Element Not Found",message:"The required timeline container element could not be found on the page.",solution:'Ensure your HTML includes a container with the class "timeline" and the correct selector.'},"invalid-config":{title:"Invalid Configuration",message:"One or more timeline configuration options are invalid.",solution:"Check your data attributes or JavaScript options and ensure they match the expected format."}}[t]||{title:"Timeline Error",message:"An unexpected error occurred while initializing the timeline.",solution:"Please check the browser console for more details."};e.classList.add("timeline--error"),e.classList.add("timeline--loaded"),e.innerHTML="";const o=document.createElement("div");o.className="timeline__error";const a=document.createElement("img");a.src=h?h+"/alert.svg":"",a.alt="Error",a.className="timeline__error-icon",a.onload=function(){try{console.info("Timeline: error icon loaded",this.naturalWidth,"px from",this.src)}catch(e){}},a.onerror=function(){this.onerror=null;try{console.warn("Timeline: error icon failed to load from",this.src||"(empty src)")}catch(e){}this.src='data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="200" height="200" fill="none" stroke="%23d32f2f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>'},a.width=200,a.style.height="auto";const r=document.createElement("h2");r.className="timeline__error-title",r.textContent=n.title;const l=document.createElement("p");l.className="timeline__error-message",l.textContent=n.message;const s=document.createElement("p");if(s.className="timeline__error-solution",s.innerHTML="<strong>Solution:</strong> "+n.solution,i){const e=document.createElement("p");e.className="timeline__error-details",e.innerHTML="<strong>Details:</strong> "+i,o.appendChild(e)}o.appendChild(a),o.appendChild(r),o.appendChild(l),o.appendChild(s),e.appendChild(o),console.error("Timeline Error ["+t+"]:",n.message,i||"");try{const o=new CustomEvent("timeline:error",{detail:{type:t,message:n.message,details:i||null,containerId:e.id||null}});window.dispatchEvent(o)}catch(e){}}function p(e){let t;if(!e||"string"!=typeof e)return 128;if(e.startsWith("#")){let i=e.substring(1);3===i.length&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);t=[parseInt(i.substring(0,2),16),parseInt(i.substring(2,4),16),parseInt(i.substring(4,6),16)]}else{if(!e.startsWith("rgb"))return 128;{const i=e.match(/\d+/g);t=i?i.map(Number):[128,128,128]}}return(299*t[0]+587*t[1]+114*t[2])/1e3}function g(e,t="undefined"!=typeof navigator&&navigator.language||"en-US"){if(!e||"string"!=typeof e)return String(e);const i=Date.parse(e);if(Number.isNaN(i)){const i=e.split(/[\/\.\-]/).map(e=>e.trim());if(3===i.length){let e=parseInt(i[0],10),n=parseInt(i[1],10),o=parseInt(i[2],10);if(!Number.isNaN(e)&&!Number.isNaN(n)&&!Number.isNaN(o)){o<100&&(o+=2e3);const i=new Date(o,e-1,n);if(!Number.isNaN(i.getTime()))return v(i,t)}}return e}return v(new Date(i),t)}function v(e,t){try{const i=new Intl.DateTimeFormat(t,{month:"long",day:"numeric",year:"numeric"});if("function"==typeof Intl.DateTimeFormat.prototype.formatToParts){const i=new Intl.DateTimeFormat(t,{month:"long",day:"numeric",year:"numeric"}).formatToParts(e);let n="",o="",a="";i.forEach(e=>{"month"===e.type&&(n=e.value),"day"===e.type&&(o=e.value),"year"===e.type&&(a=e.value)});const r=parseInt(o,10)||e.getDate();return`${n} ${r}${function(e){const t=["th","st","nd","rd"],i=e%100;return t[(i-20)%10]||t[i]||t[0]}(r)}, ${a}`}return i.format(e)}catch(t){return e.toDateString()}}function y(e,t){let i=t.nodeColor||null,n=t.lineColor||null;const o=t.navColor||null;if(i&&!n&&(n=i),n&&!i&&(i=n),i&&(e.style.setProperty("--timeline-node-color",i),e.style.setProperty("--timeline-active-outline-color",i)),n&&e.style.setProperty("--timeline-line-color",n),o){e.style.setProperty("--timeline-nav-color",o),e.style.setProperty("--timeline-nav-border",p(o)>128?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.3)");const t=p(o)>128?"#333":"#fff";e.style.setProperty("--timeline-arrow-color",t),e.setAttribute("data-arrow-color",t)}}class w{constructor(){this.swiper=null,this._container=null,this._original={}}async init(e,t,i={}){if(this._container=e.querySelector(".timeline__wrap"),!this._container)return console.warn("SwiperAdapter: No .timeline__wrap found"),null;let n=null;if(i&&i.swiperCdn&&"string"==typeof i.swiperCdn)try{const e=await import(i.swiperCdn);n=e.default||e.Swiper||e||null}catch(e){console.warn("SwiperAdapter: failed to import swiper from swiperCdn:",e)}if(!n)try{const e=await import("swiper");n=e.default||e.Swiper||e||null}catch(e){}if(!n&&"undefined"!=typeof window&&window.Swiper&&(n=window.Swiper),!n){try{const e="undefined"!=typeof Storage&&localStorage.getItem("swiperJSLib");"0"!==e&&"false"!==e&&(console.log("SwiperAdapter: Swiper library not found (tried options.swiperCdn, dynamic import, and window.Swiper)"),"undefined"!=typeof Storage&&localStorage.setItem("swiperJSLib","0"))}catch(e){console.log("SwiperAdapter: Swiper library not found (tried options.swiperCdn, dynamic import, and window.Swiper)")}return null}const o=this._container.querySelector(".timeline__items");this._original.itemsClass=o?o.className:null,this._original.itemClasses=[],o&&Array.from(o.children).forEach(e=>{this._original.itemClasses.push(e.className||"")}),this._container.classList.add("swiper"),o&&(o.classList.add("swiper-wrapper"),Array.from(o.children).forEach(e=>{e.classList.add("swiper-slide")}));const a=Object.assign({slidesPerView:"auto",freeMode:!1,spaceBetween:20,direction:"horizontal"},i||{});try{if("function"!=typeof n)console.warn("SwiperAdapter: Swiper resolved but is not a constructor"),this.swiper=null;else{this.swiper=new n(this._container,a);try{"undefined"!=typeof Storage&&localStorage.setItem("swiperJSLib","1")}catch(e){}}}catch(e){console.warn("SwiperAdapter: failed to initialize Swiper instance",e),this.swiper=null}return this.swiper}slideTo(e,t){this.swiper&&"function"==typeof this.swiper.slideTo&&this.swiper.slideTo(e,t&&t.speed)}slideBy(e,t){this.swiper&&"function"==typeof this.swiper.slideTo&&"number"==typeof this.swiper.activeIndex&&this.slideTo(this.swiper.activeIndex+e,t)}update(){this.swiper&&"function"==typeof this.swiper.update&&this.swiper.update()}destroy(){if(this.swiper&&"function"==typeof this.swiper.destroy){try{this.swiper.destroy(!0,!0)}catch(e){}this.swiper=null}if(this._container){const e=this._container.querySelector(".timeline__items");this._container.classList.remove("swiper"),e&&(e.classList.remove("swiper-wrapper"),Array.from(e.children).forEach((e,t)=>{e.classList.remove("swiper-slide"),this._original.itemClasses&&void 0!==this._original.itemClasses[t]&&(e.className=this._original.itemClasses[t])}),null!==this._original.itemsClass&&(e.className=this._original.itemsClass))}}}function b(e,t){if(!e||!t)return;const i=e.querySelector(".timeline__live-region");if(!i)return;const n=t.getAttribute("aria-labelledby");let o="";if(n){const e=document.getElementById(n);o=e?e.textContent:""}if(!o){const e=t.querySelector(".timeline__date"),i=t.querySelector(".timeline__heading");o=(e?e.textContent:"")+". "+(i?i.textContent:"")}i.textContent=o}function _(e,t){!function(e){if(!e)return;const t=e.querySelector(".timeline-nav-button--prev"),i=e.querySelector(".timeline-nav-button--next"),n=Array.from(e.querySelectorAll(".timeline__item"));let o=1;t&&(t.tabIndex=o++),n.forEach(e=>{e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"),e.tabIndex=o++}),i&&(i.tabIndex=o++)}(e),function(e,t){if(!e)return;const i=e.querySelector(".timeline-nav-button--prev"),n=e.querySelector(".timeline-nav-button--next"),o=e.__keyboardHandlers;if(o){try{e.removeEventListener("keydown",o.keydown)}catch(e){}if(i&&o.prevKey)try{i.removeEventListener("keydown",o.prevKey)}catch(e){}if(n&&o.nextKey)try{n.removeEventListener("keydown",o.nextKey)}catch(e){}}const a=function(e){const t=document.activeElement;if("Enter"!==e.key&&" "!==e.key||t!==i&&t!==n)e.shiftKey&&("ArrowLeft"===e.key&&i?(e.preventDefault(),i.focus()):"ArrowRight"===e.key&&n&&(e.preventDefault(),n.focus()));else{e.preventDefault();try{t.click()}catch(e){}}},r=function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click())},l=function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click())},s=function(){setTimeout(()=>{const t=e.querySelector(".timeline__item--active");t&&b(e,t)},0)};e.addEventListener("keydown",a);const d=function(e){const t=e.target&&e.target.tagName?e.target.tagName.toLowerCase():"";"input"===t||"textarea"===t||e.target.isContentEditable||e.shiftKey&&("ArrowLeft"===e.key&&i?(e.preventDefault(),i.focus()):"ArrowRight"===e.key&&n&&(e.preventDefault(),n.focus()))};document.addEventListener("keydown",d),i&&i.addEventListener("keydown",r),n&&n.addEventListener("keydown",l),i&&i.addEventListener("click",s),n&&n.addEventListener("click",s),e.__keyboardHandlers={keydown:a,prevKey:r,nextKey:l,globalKey:d,prev:i,next:n,navClick:s};const c=Array.from(e.querySelectorAll(".timeline__item")),m=function(i){if(!(e.classList.contains("timeline--horizontal")?["ArrowLeft","ArrowRight","Home","End"]:["ArrowUp","ArrowDown","Home","End"]).includes(i.key))return;i.preventDefault();let n=0;"ArrowLeft"!==i.key&&"ArrowUp"!==i.key||(n=-1),"ArrowRight"!==i.key&&"ArrowDown"!==i.key||(n=1);const o=c,a=o.indexOf(i.currentTarget);let r=a;r="Home"===i.key?0:"End"===i.key?o.length-1:Math.max(0,Math.min(o.length-1,a+n));const l=o[r];t&&"function"==typeof t.setCurrentIndex&&"function"==typeof t.updatePosition&&(t.setCurrentIndex(r),t.updatePosition()),l&&(l.focus(),b(e,l))};c.forEach(e=>{e.addEventListener("keydown",m)}),e.__keyboardHandlers.itemKey=m,e.__keyboardHandlers.items=c}(e,t),function(e){if(!e)return;let t=e.querySelector(".timeline__live-region");t||(t=document.createElement("div"),t.className="timeline__live-region sr-only",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),e.appendChild(t))}(e)}function x(e){if(!e||!e.__keyboardHandlers)return;const t=e.__keyboardHandlers;try{e.removeEventListener("keydown",t.keydown)}catch(e){}if(t.prev){try{t.prev.removeEventListener("keydown",t.prevKey)}catch(e){}try{t.prev.removeEventListener("click",t.navClick)}catch(e){}}if(t.next){try{t.next.removeEventListener("keydown",t.nextKey)}catch(e){}try{t.next.removeEventListener("click",t.navClick)}catch(e){}}if(t.globalKey)try{document.removeEventListener("keydown",t.globalKey)}catch(e){}t.items&&t.itemKey&&t.items.forEach(e=>{try{e.removeEventListener("keydown",t.itemKey)}catch(e){}}),delete e.__keyboardHandlers}function E(e=document){(e||document).querySelectorAll(".timeline__content").forEach(e=>{const t=e.querySelector(".timeline__image");t?t.complete?0===t.naturalWidth?e.classList.add("no-image"):e.classList.remove("no-image"):(t.addEventListener("load",()=>e.classList.remove("no-image"),{once:!0}),t.addEventListener("error",()=>e.classList.add("no-image"),{once:!0})):e.classList.add("no-image")})}function L(e=document){(e||document).querySelectorAll(".timeline__content").forEach(e=>{const t=e.querySelector(".timeline__summary");!!(t&&t.textContent&&t.textContent.trim().length>0)?e.classList.remove("no-summary"):e.classList.add("no-summary")})}function S(e=document){E(e),L(e),document.querySelectorAll(".timeline__items").forEach(e=>{new MutationObserver(()=>{E(e),L(e)}).observe(e,{childList:!0,subtree:!0})})}function A(e,t){t&&t.length&&t.forEach(function(e){if("1"===e.getAttribute("data-modal-bound"))return;!function(e){if(!e)return;const t=e.querySelector(".timeline__content")||e;if(!e.hasAttribute("data-modal-title")){const i=t.querySelector("h1,h2,h3,h4,h5,h6");i&&i.textContent&&e.setAttribute("data-modal-title",i.textContent.trim())}if(!e.hasAttribute("data-modal-content")){const i=t.querySelector("p");i&&i.textContent&&e.setAttribute("data-modal-content",i.textContent.trim())}if(!e.hasAttribute("data-modal-image")){const i=t.querySelector("img");i&&i.getAttribute("src")&&e.setAttribute("data-modal-image",i.getAttribute("src"))}}(e),function(e){if(!e)return;if(e.hasAttribute("aria-label"))return;if(e.hasAttribute("aria-labelledby"))return;const t=e.dataset&&e.dataset.ariaLabel;let i=t&&String(t).trim();if(!i||""===i){const t=e.querySelector(".timeline__date"),n=e.querySelector(".timeline__heading"),o=t?t.textContent.trim():"",a=n?n.textContent.trim():"";if(o||a){const t=o?g(o):"";i=(o?`Date: ${t}. `:"")+(a?`Title: ${a}`:"");const n=e.getAttribute("data-node-id");n&&(i=`Node ${n}: `+i)}}if(i&&""!==i){const t="tl-label-"+Math.random().toString(36).slice(2,9),n=document.createElement("span");n.className="sr-only",n.id=t,n.textContent=i,e.appendChild(n),e.setAttribute("aria-labelledby",t)}}(e);(e.hasAttribute("data-modal-title")||e.hasAttribute("data-modal-content")||e.hasAttribute("data-modal-image")||e.hasAttribute("data-modal-html"))&&(e.addEventListener("click",function(t){t.preventDefault(),s(e)}),e.setAttribute("data-modal-bound","1"))})}function T(e,t){return"left"===e?'<svg xmlns="http://www.w3.org/2000/svg" width="7.8" height="14" style="display:block;margin:auto;"><path fill="none" stroke="'+t+'" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M6.8 1L1 7l5.8 6"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="7.8" height="14" style="display:block;margin:auto;"><path fill="none" stroke="'+t+'" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M1 1l5.8 6L1 13"/></svg>'}function C(e,t,i){const n=parseInt(e,10);return Number.isNaN(n)?t:Math.max(t,Math.min(i,n))}function I(e,t){if(!e||!t||"undefined"==typeof window||!window.history)return;if(!function(e){if("undefined"==typeof window||!window.location)return!1;const t=new URLSearchParams(window.location.search);if(!t.has("id"))return!1;const i=t.get("timeline");return!(i&&e&&e.id)||i===e.id}(e))return;const i=new URL(window.location.href),n=i.searchParams;e.id&&n.set("timeline",e.id),n.set("id",String(t)),i.search=n.toString(),window.history.replaceState({},"",i.toString())}function k(e,t){const n=[],o="Timeline:";let a,r=window.innerWidth;const l={minWidth:{type:"integer",defaultValue:600},maxWidth:{type:"integer",defaultValue:600},horizontalStartPosition:{type:"string",acceptedValues:["bottom","top"],defaultValue:"top"},mode:{type:"string",acceptedValues:["horizontal","vertical"],defaultValue:"vertical"},moveItems:{type:"integer",defaultValue:1},rtlMode:{type:"boolean",acceptedValues:[!0,!1],defaultValue:!1},startIndex:{type:"integer",defaultValue:0},verticalStartPosition:{type:"string",acceptedValues:["left","right"],defaultValue:"left"},verticalTrigger:{type:"string",defaultValue:"15%"},useSwiper:{type:"string",acceptedValues:["false","true","auto"],defaultValue:"false"},sameSideNodes:{type:"string",acceptedValues:["top","bottom","left","right","true","false"],defaultValue:"false"}};function s(e,t,i){const n="left";let o=e.sameSideNodes;return void 0===o||!1===o||"false"===o?null:"true"===o||!0===o?"horizontal"===t?e.horizontalStartPosition||"top":e.verticalStartPosition||n:(o=String(o).toLowerCase(),"horizontal"===t?"top"===o||"bottom"===o?o:"left"===o?"top":"right"===o?"bottom":"top":e.verticalStartPosition?e.verticalStartPosition:"top"===o?i?"right":"left":"bottom"===o?i?"left":"right":"left"===o||"right"===o?o:n)}function d(e,t,i){t.classList.add(i),e.parentNode.insertBefore(t,e),t.appendChild(e)}function c(e,t){const i=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=l.verticalTrigger.defaultValue.match(/(\d*\.?\d*)(.*)/);let a=t.unit,r=t.value,s=n;return"px"===a&&r>=n&&(console.warn('The value entered for the setting "verticalTrigger" is larger than the window height. The default value will be used instead.'),[,r,a]=o),"px"===a?s=parseInt(s-r,10):"%"===a&&(s=parseInt(s*((100-r)/100),10)),i.top<=s&&i.left<=(window.innerWidth||document.documentElement.clientWidth)&&i.top+i.height>=0&&i.left+i.width>=0}function u(e,t){e.style.webkitTransform=t,e.style.msTransform=t,e.style.transform=t}function h(e,t){const i=C(t,0,Math.max(0,e.items.length-1)),n=e.items[i].offsetLeft,o=window.getComputedStyle(e.timelineEl),a=parseInt(o.paddingLeft,10)||0,r=parseInt(o.paddingRight,10)||0,l=e.wrap.offsetWidth,s=e.items[i].offsetWidth;let d=n-a;const c=Math.max(0,n+s-l+r);d=Math.max(d,c),d=Math.max(0,d);const m=`translate3d(-${d}px, 0, 0)`;u(e.scroller,m)}function p(e,t){e.items.forEach(e=>e.classList.remove("timeline__item--active")),e.items[t]&&e.items[t].classList.add("timeline__item--active")}function g(e){e.timelineEl.classList.add("timeline--horizontal"),function(e){if(!e||!e.classList.contains("timeline--horizontal"))return;const t={min:150,max:200,default:200},i={min:135,max:180,default:180},n={min:80,max:100,default:100},o={min:14,max:18,default:18},a={min:11,max:13,default:11},r=window.innerHeight-180,l=2*i.max+90;let s=1;function d(e){const t=Math.round(e.default*s);return Math.max(e.min,Math.min(e.max,t))}r<l&&(s=Math.max(.75,r/l)),e.style.setProperty("--timeline-h-node-width",d(t)+"px"),e.style.setProperty("--timeline-h-node-min-height",d(i)+"px"),e.style.setProperty("--timeline-h-image-size",d(n)+"px"),e.style.setProperty("--timeline-h-title-font-size",d(o)+"px"),e.style.setProperty("--timeline-h-text-font-size",d(a)+"px")}(e.timelineEl),function(e){window.innerWidth>e.settings.minWidth&&(function(){const t=getComputedStyle(e.timelineEl),i=parseInt(t.getPropertyValue("--timeline-h-node-width"))||200;e.itemWidth=i,e.items.forEach(t=>{t.style.width=`${e.itemWidth}px`}),e.scrollerWidth=e.itemWidth*e.items.length,e.scroller.style.width=`${e.scrollerWidth}px`}(),function(){let t=0,i=0;e.items.forEach((e,n)=>{e.style.height="auto";const o=e.offsetHeight;n%2==0?i=o>i?o:i:t=o>t?o:t});const n=`translateY(${i}px)`,o=s(e.settings,"horizontal",e.settings.rtlMode)||e.settings.horizontalStartPosition,a=!!s(e.settings,"horizontal",e.settings.rtlMode);if(a?e.timelineEl.classList.add("timeline--same-side"):e.timelineEl.classList.remove("timeline--same-side"),e.items.forEach((e,r)=>{r%2==0?(e.style.height=`${i}px`,"bottom"===o?(e.classList.add("timeline__item--bottom"),a||u(e,n)):e.classList.add("timeline__item--top")):(e.style.height=`${t}px`,a?"bottom"===o?e.classList.add("timeline__item--bottom"):e.classList.add("timeline__item--top"):"bottom"!==o?(e.classList.add("timeline__item--bottom"),u(e,n)):e.classList.add("timeline__item--top"))}),e.evenIndexTallest=i,e.oddIndexTallest=t,a){const n=Math.max(i,t);e.scroller.style.height=`${n+10}px`}else e.scroller.style.height=`${i+t}px`;try{e.computedVisibleCount=Math.floor(e.wrap.offsetWidth/e.itemWidth)||1}catch(t){e.computedVisibleCount=1}}())}(e);const t=Math.floor(e.wrap.offsetWidth/e.itemWidth)||1;e.computedVisibleCount=t,e.settings.rtlMode?e.currentIndex=e.items.length>t?e.items.length-t:0:e.currentIndex=e.settings.startIndex,e.activeIndex=e.currentIndex,h(e,e.currentIndex),p(e,e.activeIndex),function(e){const t=e.wrap.offsetWidth,i=Math.floor(t/e.itemWidth);if(e.items.length>i){const t=document.createElement("button"),i=document.createElement("button"),n=s(e.settings,"horizontal",e.settings.rtlMode)||e.settings.horizontalStartPosition;let o;o=s(e.settings,"horizontal",e.settings.rtlMode)?"bottom"===n?30:e.items[0].offsetHeight-30:e.items[0].offsetHeight,t.className="timeline-nav-button timeline-nav-button--prev",i.className="timeline-nav-button timeline-nav-button--next",t.textContent="Previous",t.title="Go to previous items",i.textContent="Next",i.title="Go to next items",t.setAttribute("aria-label","Previous timeline items"),i.setAttribute("aria-label","Next timeline items"),t.style.top=`${o}px`,i.style.top=`${o}px`;const a=e.timelineEl.getAttribute("data-arrow-color")||"#333";t.innerHTML=T("left",a),i.innerHTML=T("right",a);const r=Math.max(0,e.items.length-1);e.activeIndex<=0?(t.classList.add("timeline-nav-button--at-start"),t.title="Already at beginning of timeline",t.setAttribute("aria-disabled","true")):t.setAttribute("aria-disabled","false"),e.activeIndex>=r?(i.classList.add("timeline-nav-button--at-end"),i.title="Already at end of timeline",i.setAttribute("aria-disabled","true")):i.setAttribute("aria-disabled","false"),e.timelineEl.appendChild(t),e.timelineEl.appendChild(i)}}(e),function(e){const t=e.timelineEl.querySelector(".timeline-divider");t&&e.timelineEl.removeChild(t);const i=s(e.settings,"horizontal",e.settings.rtlMode)||e.settings.horizontalStartPosition;let n;n=s(e.settings,"horizontal",e.settings.rtlMode)?"bottom"===i?30:e.items[0].offsetHeight-30:e.items[0].offsetHeight;const o=document.createElement("span");o.className="timeline-divider",o.style.top=`${n}px`,e.timelineEl.appendChild(o)}(e),function(e){const t=e.timelineEl.querySelectorAll(".timeline-nav-button"),i=e.timelineEl.querySelector(".timeline-nav-button--prev"),n=e.timelineEl.querySelector(".timeline-nav-button--next"),o=e.wrap.offsetWidth;Math.floor(o/e.itemWidth);const a=parseInt(e.settings.moveItems,10),r=function(t){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();const o=Math.max(0,e.items.length-1),r=this.classList.contains("timeline-nav-button--next")?1:-1;let l=e.activeIndex+r*a;if(r<0&&e.activeIndex>0){const t=Math.floor(e.activeIndex/a);let i;i=e.activeIndex%a===0?(t-1)*a:t*a,l=Math.max(0,i)}else if(r>0&&e.activeIndex<o){const t=(Math.floor(e.activeIndex/a)+1)*a;l=Math.min(o,t)}if(l=C(l,0,o),l===e.activeIndex)return;e.currentIndex=l,e.activeIndex=l,e.activeIndex<=0?(i.classList.add("timeline-nav-button--at-start"),i.title="Already at beginning of timeline",i.setAttribute("aria-disabled","true")):(i.classList.remove("timeline-nav-button--at-start"),i.title="Go to previous items",i.setAttribute("aria-disabled","false")),e.activeIndex>=o?(n.classList.add("timeline-nav-button--at-end"),n.title="Already at end of timeline",n.setAttribute("aria-disabled","true")):(n.classList.remove("timeline-nav-button--at-end"),n.title="Go to next items",n.setAttribute("aria-disabled","false")),h(e,e.activeIndex),p(e,e.activeIndex);const s=e.items[e.activeIndex],d=s&&s.getAttribute("data-node-id");d&&I(e.timelineEl,d),this.blur()};Array.from(t).forEach(t=>{t.addEventListener("click",r),e.listeners.push({element:t,type:"click",handler:r})})}(e);const n=e.timelineEl.id||e.timelineEl.getAttribute("data-timeline-id");if(n){i[n]={setCurrentIndex:function(t){const i=e.wrap.offsetWidth,n=Math.floor(i/e.itemWidth),o=Math.max(0,e.items.length-n);e.activeIndex=Math.max(0,Math.min(t,e.items.length-1)),e.currentIndex=Math.max(0,Math.min(t,o))},updatePosition:function(){h(e,e.currentIndex),p(e,e.activeIndex);const t=e.timelineEl.querySelector(".timeline-nav-button--prev"),i=e.timelineEl.querySelector(".timeline-nav-button--next");if(t&&i){const n=Math.max(0,e.items.length-1);e.activeIndex<=0?(t.classList.add("timeline-nav-button--at-start"),t.title="Already at beginning of timeline"):(t.classList.remove("timeline-nav-button--at-start"),t.title="Go to previous items"),e.activeIndex>=n?(i.classList.add("timeline-nav-button--at-end"),i.title="Already at end of timeline"):(i.classList.remove("timeline-nav-button--at-end"),i.title="Go to next items")}const n=e.items[e.activeIndex],o=n&&n.getAttribute("data-node-id");o&&I(e.timelineEl,o)}};const t=i[n];e.items.forEach((i,n)=>{const o=()=>{e.timelineEl.classList.contains("timeline--horizontal")&&t&&t.setCurrentIndex&&t.updatePosition&&(t.setCurrentIndex(n),t.updatePosition())};i.addEventListener("click",o),e.listeners.push({element:i,type:"click",handler:o})}),async function(){try{if(!(e.settings&&(e.settings.swiperAdapter||e.settings.useSwiper)))return;if(e.settings.swiperAdapter){const t=e.settings.swiperAdapter;e.adapter="function"==typeof t?t():t}else e.adapter=new w;e.adapter&&"function"==typeof e.adapter.init&&await e.adapter.init(e.timelineEl,i[n],e.settings.swiperOptions||{})}catch(e){console.warn("Timeline: Swiper adapter initialization failed",e)}}()}}function v(e){if(e.listeners&&e.listeners.length>0&&(e.listeners.forEach(({element:e,type:t,handler:i})=>{e.removeEventListener(t,i)}),e.listeners=[]),e.observer&&(e.observer.disconnect(),e.observer=null),e.adapter&&"function"==typeof e.adapter.destroy){try{e.adapter.destroy()}catch(e){}e.adapter=null}e.timelineEl.classList.remove("timeline--horizontal","timeline--mobile"),e.scroller.removeAttribute("style"),e.items.forEach(e=>{e.removeAttribute("style"),e.classList.remove("animated","fadeIn","timeline__item--left","timeline__item--right")});try{x(e.timelineEl)}catch(e){}const t=e.timelineEl.querySelectorAll(".timeline-nav-button");Array.from(t).forEach(e=>{e.parentNode.removeChild(e)})}function b(){n.forEach(e=>{e.timelineEl.style.opacity=0,e.timelineEl.classList.contains("timeline--loaded")||e.items.forEach(e=>{d(e.querySelector(".timeline__content"),document.createElement("div"),"timeline__content__wrap"),d(e.querySelector(".timeline__content__wrap"),document.createElement("div"),"timeline__item__inner")}),v(e),window.innerWidth<=e.settings.minWidth&&e.timelineEl.classList.add("timeline--mobile");let t=!1;("horizontal"===e.settings.mode&&window.innerWidth>e.settings.minWidth||"vertical"===e.settings.mode&&window.innerWidth>e.settings.maxWidth)&&(t=!0),t?g(e):function(e){let t=0;e.items.forEach((i,n)=>{i.classList.remove("animated","fadeIn"),!c(i,e.settings.verticalTrigger)&&n>0?i.classList.add("animated"):t=n;const o=s(e.settings,"vertical",e.settings.rtlMode)||e.settings.verticalStartPosition,a=!!s(e.settings,"vertical",e.settings.rtlMode);a?e.timelineEl.classList.add("timeline--same-side"):e.timelineEl.classList.remove("timeline--same-side"),a?"right"===o?i.classList.add("timeline__item--right"):i.classList.add("timeline__item--left"):n%2==("left"===o?1:0)&&window.innerWidth>e.settings.minWidth?i.classList.add("timeline__item--right"):i.classList.add("timeline__item--left")});for(let i=0;i<t;i+=1)e.items[i].classList.remove("animated","fadeIn");if("IntersectionObserver"in window){const t={rootMargin:"%"===e.settings.verticalTrigger.unit?`${e.settings.verticalTrigger.value}%`:`${e.settings.verticalTrigger.value}px`,threshold:.01},i=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&e.target.classList.add("fadeIn")})},t);e.items.forEach(e=>{e.classList.contains("animated")&&i.observe(e)}),e.observer=i}else{const t=()=>{e.items.forEach(t=>{c(t,e.settings.verticalTrigger)&&t.classList.add("fadeIn")})};window.addEventListener("scroll",t),e.listeners.push({element:window,type:"scroll",handler:t})}}(e),e.timelineEl.classList.add("timeline--loaded"),S(e.timelineEl);try{const t=e.timelineEl.id||e.timelineEl.getAttribute("data-timeline-id"),n={id:t,settings:e.settings,api:i[t]},o=new CustomEvent("timeline:initialized",{detail:n});try{e.timelineEl.dispatchEvent(o)}catch(e){}try{document.dispatchEvent(new CustomEvent("timeline:initialized",{detail:n}))}catch(e){}}catch(e){}}),setTimeout(()=>{n.forEach(e=>{e.timelineEl.style.opacity=1})},500)}e.length&&Array.from(e).forEach(function(e){if(e&&e.getAttribute&&"1"===e.getAttribute("data-timeline-initialized"))return;const i=e.id?`#${e.id}`:`.${e.className}`,a="could not be found as a direct descendant of",r=e.dataset;let s,d,c;const m={};try{if(s=e.querySelector(".timeline__wrap"),!s)throw new Error(`${o} .timeline__wrap ${a} ${i}`);if(d=s.querySelector(".timeline__items"),!d)throw new Error(`${o} .timeline__items ${a} .timeline__wrap`);if(c=[].slice.call(d.children,0),!c||0===c.length)return}catch(t){return console.warn(t.message),f(e,"missing-element",t.message),!1}Object.keys(l).forEach(e=>{if(m[e]=l[e].defaultValue,"minWidth"===e){let e;void 0!==r.minWidth&&(e=r.minWidth),void 0!==r.minwidth&&(e=r.minwidth),void 0!==r.forceVerticalMode&&(e=r.forceVerticalMode),void 0!==r.forceverticalmode&&(e=r.forceverticalmode),void 0===e&&t&&(void 0!==t.minWidth?e=t.minWidth:void 0!==t.forceVerticalMode&&(e=t.forceVerticalMode)),void 0!==e&&(m.minWidth=e)}else if("maxWidth"===e){let e;void 0!==r.maxWidth&&(e=r.maxWidth),void 0!==r.maxwidth&&(e=r.maxwidth),void 0===e&&t&&void 0!==t.maxWidth&&(e=t.maxWidth),void 0!==e&&(m.maxWidth=e)}else r[e]?m[e]=r[e]:t&&void 0!==t[e]&&(m[e]=t[e]);var i,n;"integer"===l[e].type?m[e]&&(n=e,"number"==typeof(i=m[e])||i%1==0||(console.warn(`${o} The value "${i}" entered for the setting "${n}" is not an integer.`),0))||(m[e]=l[e].defaultValue):"string"===l[e].type&&l[e].acceptedValues&&-1===l[e].acceptedValues.indexOf(m[e])&&(console.warn(`${o} The value "${m[e]}" entered for the setting "${e}" was not recognised.`),m[e]=l[e].defaultValue)}),function(){const i=e.dataset,n=function(e){return void 0!==i[e]?i[e]:void 0!==i[e&&e.toLowerCase()]?i[e.toLowerCase()]:void 0};let o=n("nodeColor"),a=n("lineColor"),r=n("navColor");t&&(void 0!==t.nodeColor&&(o=t.nodeColor),void 0!==t.lineColor&&(a=t.lineColor),void 0!==t.navColor&&(r=t.navColor)),(o||a||r)&&y(e,{nodeColor:o,lineColor:a,navColor:r})}();const u=l.verticalTrigger.defaultValue.match(/(\d*\.?\d*)(.*)/),h=m.verticalTrigger.match(/(\d*\.?\d*)(.*)/);let[,p,g]=h,v=!0;if(p||(console.warn(`${o} No numercial value entered for the 'verticalTrigger' setting.`),v=!1),"px"!==g&&"%"!==g&&(console.warn(`${o} The setting 'verticalTrigger' must be a percentage or pixel value.`),v=!1),"%"===g&&(p>100||p<0)?(console.warn(`${o} The 'verticalTrigger' setting value must be between 0 and 100 if using a percentage value.`),v=!1):"px"===g&&p<0&&(console.warn(`${o} The 'verticalTrigger' setting value must be above 0 if using a pixel value.`),v=!1),!1===v&&([,p,g]=u),m.verticalTrigger={unit:g,value:p},m.moveItems>c.length&&(console.warn(`${o} The value of "moveItems" (${m.moveItems}) is larger than the total number of items (${c.length}). It has been reduced to ${c.length}.`),m.moveItems=c.length),m.startIndex<0?(console.warn(`${o} The 'startIndex' setting must be >= 0. The value of 0 has been used instead.`),m.startIndex=0):m.startIndex>Math.max(0,c.length-1)&&(console.warn(`${o} The 'startIndex' setting is larger than the last index for this timeline. It has been reduced to ${Math.max(0,c.length-1)}.`),m.startIndex=Math.max(0,c.length-1)),void 0!==r.useSwiper||void 0!==r.useswiper){const e=void 0!==r.useSwiper?r.useSwiper:r.useswiper;m.useSwiper="true"===e||"auto"===e?e:"true"===e}t&&(void 0!==t.useSwiper&&(m.useSwiper=t.useSwiper),void 0!==t.swiperOptions&&(m.swiperOptions=t.swiperOptions),void 0!==t.swiperAdapter&&(m.swiperAdapter=t.swiperAdapter)),A(0,c),e.id||e.setAttribute("data-timeline-id","timeline-"+Date.now()+"-"+Math.random().toString(36).substr(2,9));try{e.setAttribute("data-timeline-initialized","1")}catch(e){}n.push({timelineEl:e,wrap:s,scroller:d,items:c,settings:m,listeners:[],adapter:null})});try{b();try{m()}catch(e){}const e=()=>{clearTimeout(a),a=setTimeout(()=>{const e=window.innerWidth;e!==r&&(b(),r=e)},250)};window.addEventListener("resize",e),k._test_destroyAll=function(){n.forEach(e=>{try{v(e)}catch(e){}}),n.length=0,a&&(clearTimeout(a),a=null);try{window.removeEventListener("resize",e)}catch(e){}}}catch(e){console.error("Timeline initialization failed:",e)}}document.addEventListener("timeline:initialized",function(e){try{const t=e.target&&e.target.classList&&e.target.classList.contains("timeline")?e.target:e.detail&&e.detail.id?document.getElementById(e.detail.id):null,i=e.detail&&e.detail.api?e.detail.api:void 0;t&&_(t,i)}catch(e){}});function N(e,t,i){const n=document.querySelector(e);if(!n)return console.error("Timeline: Container not found:",e),null;n.classList.remove("timeline--error");let o=n.querySelector(".timeline__items");if(o)o.innerHTML="",o.setAttribute("role","list");else{const e=document.createElement("div");e.className="timeline__wrap",o=document.createElement("div"),o.className="timeline__items",o.setAttribute("role","list"),e.appendChild(o),n.appendChild(e)}if(i&&(function(e,t){t.layoutMode&&e.setAttribute("data-mode",t.layoutMode),void 0!==t.moveItems&&e.setAttribute("data-move-items",t.moveItems),void 0!==t.minWidth&&e.setAttribute("data-min-width",t.minWidth),void 0!==t.maxWidth&&e.setAttribute("data-max-width",t.maxWidth),void 0!==t.startIndex&&e.setAttribute("data-start-index",t.startIndex),void 0!==t.horizontalStartPosition&&e.setAttribute("data-horizontal-start-position",t.horizontalStartPosition),void 0!==t.verticalStartPosition&&e.setAttribute("data-vertical-start-position",t.verticalStartPosition),void 0!==t.verticalTrigger&&e.setAttribute("data-vertical-trigger",t.verticalTrigger),void 0!==t.rtlMode&&e.setAttribute("data-rtl-mode",String(t.rtlMode)),void 0!==t.nodeColor&&e.setAttribute("data-node-color",t.nodeColor),void 0!==t.lineColor&&e.setAttribute("data-line-color",t.lineColor),void 0!==t.navColor&&e.setAttribute("data-nav-color",t.navColor),void 0!==t.sameSideNodes&&e.setAttribute("data-same-side-nodes",t.sameSideNodes),void 0!==t.useSwiper&&e.setAttribute("data-use-swiper",t.useSwiper)}(n,i),y(n,i),i.timelineName&&""!==i.timelineName.trim())){const e=n.previousElementSibling;if(e&&e.classList.contains("timeline__title"))e.textContent=i.timelineName;else{const e=document.createElement("h1");e.className="timeline__title",e.textContent=i.timelineName,n.parentNode.insertBefore(e,n)}n.setAttribute("data-timeline-name",i.timelineName)}return Array.isArray(t)&&0!==t.length?(t.forEach(function(e){o.appendChild(function(e){const t={id:(i=e).id||null,date:i.date||"DD/MM/YYYY",heading:i.heading||"Node Title",summary:i.summary||"Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident.",content:i.content||"<p>Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate.</p><p>Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.</p>",image:i.image||null};var i;const n=document.createElement("div");if(n.className="timeline__item",n.setAttribute("role","listitem"),n.setAttribute("tabindex","0"),t.id&&(n.setAttribute("data-node-id",t.id),!n.id))try{n.id=String(t.id)}catch(e){}const o=document.createElement("div");o.className="timeline__content";const a=document.createElement("div");if(a.className="timeline__date",a.textContent=t.date,o.appendChild(a),t.image){const e=document.createElement("img");e.src=t.image,e.className="timeline__image",e.alt=t.heading,e.loading="lazy",e.onerror=function(){console.error("Timeline: Image failed to load:",t.image),this.src=h+"/missing-image.svg",this.alt="Image not found"},o.appendChild(e)}const r=document.createElement("h3");r.className="timeline__heading",r.textContent=t.heading,o.appendChild(r);const l=document.createElement("div");l.className="timeline__summary",l.textContent=t.summary,o.appendChild(l),n.appendChild(o);const s=e&&(e.ariaLabel||e["aria-label"]||e.aria_label);let d="";s&&""!==String(s).trim()?d=String(s).trim():(d=`Date: ${g(t.date)}. Title: ${t.heading}`,t.id&&(d=`Node ${t.id}: `+d));if(d){const e="tl-label-"+Math.random().toString(36).slice(2,9),t=document.createElement("span");t.className="sr-only",t.id=e,t.textContent=d,n.appendChild(t),n.setAttribute("aria-labelledby",e)}const c=document.createElement("div");return c.className="timeline__modal-content",c.innerHTML=function(e){let t=e;return t=t.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,""),t=t.replace(/<form[^>]*>[\s\S]*?<\/form>/gi,""),t=t.replace(/<input[^>]*>/gi,""),t=t.replace(/<h1/gi,"<h3"),t=t.replace(/<\/h1>/gi,"</h3>"),t=t.replace(/<h2/gi,"<h3"),t=t.replace(/<\/h2>/gi,"</h3>"),t.trim()}(t.content),n.appendChild(c),n.addEventListener("click",function(e){e.preventDefault(),"function"==typeof window.openTimelineModal&&window.openTimelineModal(n)}),n.addEventListener("keydown",function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),"function"==typeof window.openTimelineModal&&window.openTimelineModal(n))}),n}(e))}),n):(f(n,"no-data","No timeline items provided"),null)}function M(e,t,i){const n=N(e,t,i);n&&W(n).then(()=>{k([n],i||{})})}function q(e,t){const i=document.querySelector(t);if(!i)return console.error("Timeline: Container not found:",t),void f(null,"missing-element","Timeline container not found: "+t);const n=function(){try{return new URL(e,window.location.href).href}catch(t){return e}}();console.info("Timeline: loading JSON from",n,"(from attribute",e+")");const o="timeline_cache_"+n;let a=null,r=null;if("undefined"!=typeof Storage)try{const e=localStorage.getItem(o);if(e){const t=JSON.parse(e);a=t.data,r=t.timestamp}}catch(e){console.warn("Timeline: Failed to parse cached data")}fetch(n).then(e=>{if(!e.ok)throw new Error("Failed to load: "+e.statusText);return e.json()}).then(e=>{if((!a||!e.lastupdated||new Date(e.lastupdated)>new Date(r))&&e.nodes&&"undefined"!=typeof Storage)try{localStorage.setItem(o,JSON.stringify({data:e.nodes,timestamp:e.lastupdated||(new Date).toISOString()}))}catch(e){console.warn("Timeline: Unable to cache data",e)}const n=e.nodes||e,l=Object.assign({},e);delete l.nodes,N(t,n,l),W(i).then(()=>{k([i],{}),P(i),m()})}).catch(e=>{console.error("Timeline: Error loading JSON:",e),a&&a.length>0?(console.log("Timeline: Using cached data as fallback"),N(t,a,{}),W(i).then(()=>{k([i],{}),P(i)})):f(i,"load-failed","Failed to load timeline data")})}function W(e){if(!e)return Promise.resolve();const t=Array.from(e.querySelectorAll("img"));return 0===t.length?Promise.resolve():new Promise(e=>{let i=t.length;const n=()=>{i-=1,i<=0&&e()};t.forEach(e=>{if(e.complete)n();else{const t=()=>{e.removeEventListener("load",t),e.removeEventListener("error",t),n()};e.addEventListener("load",t),e.addEventListener("error",t)}}),setTimeout(()=>e(),1e3)})}function P(e){if(!e)return;const t=e.previousElementSibling;t&&t.classList.contains("timeline__title")&&(t.offsetHeight,t.classList.add("timeline__title--visible"))}function D(e){if("undefined"!=typeof Storage)if(e){const t="timeline_cache_"+e;localStorage.removeItem(t),console.log("Timeline: Cleared cache for",e)}else{const e=Object.keys(localStorage);let t=0;e.forEach(e=>{e.startsWith("timeline_cache_")&&(localStorage.removeItem(e),t++)}),console.log("Timeline: Cleared",t,"cache(s)")}else console.warn("Timeline: localStorage not supported")}function $(e,t,i){return N(e,t,i)}function z(){if(k&&"function"==typeof k._test_destroyAll)try{k._test_destroyAll()}catch(e){}try{document.querySelectorAll(".timeline").forEach(e=>x(e))}catch(e){}try{c()}catch(e){}}return"undefined"!=typeof window&&(window.timeline=k,window.destroyTimelines=z,window.timelineFromData=M,window.renderTimelineFromData=N,window.processTimelineData=$,window.loadDataFromJson=q,window.clearTimelineCache=D,window.createTimelineModal=l,window.openTimelineModal=s,window.closeTimelineModal=d,window.handleTimelineDeepLinking=m,window.navigateTimelineToNodeIndex=u),document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-json-config]").forEach(function(e){const t=e.getAttribute("data-json-config");if(!t)return;const i=(e.className||"").split(" ")[0],n=e.id?"#"+e.id:i?"."+i:null;n&&q(t,n)})}),"undefined"!=typeof window&&window.jQuery&&(window.jQuery.fn.timeline=function(e){return k(this,e),this}),e.clearTimelineCache=D,e.closeTimelineModal=d,e.createTimelineModal=l,e.destroyTimelineModal=c,e.destroyTimelines=z,e.handleDeepLinking=m,e.loadDataFromJson=q,e.navigateToNodeIndex=u,e.openTimelineModal=s,e.processTimelineData=$,e.renderTimelineFromData=N,e.timeline=k,e.timelineFromData=M,e}({});
|
|
2
2
|
//# sourceMappingURL=timeline.min.js.map
|