motimeline 2.13.1 → 2.13.2

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,6 +1,6 @@
1
- "use strict";var A=Object.defineProperty;var S=(l,e,t)=>e in l?A(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var _=(l,e,t)=>S(l,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});/*!
2
- * moTimeline v2.13.1
1
+ "use strict";var b=Object.defineProperty;var E=(l,e,t)=>e in l?b(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var _=(l,e,t)=>E(l,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});/*!
2
+ * moTimeline v2.13.2
3
3
  * Responsive two-column timeline layout library
4
4
  * https://github.com/MattOpen/moTimeline
5
5
  * MIT License
6
- */const h=new WeakMap,b={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0,animate:!1,renderCard:null,adSlots:null},C="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function y(){const l=window.innerWidth;return l<600?"xs":l<992?"sm":l<1200?"md":"lg"}function L(l,e=100){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>l(...s),e)}}function v(l){return l?{o:l.offsetTop,h:l.offsetHeight,gppu:l.offsetTop+l.offsetHeight}:{o:0,h:0,gppu:0}}function w(l,e){const t=[];let s=l.previousElementSibling;for(;s;)(!e||s.matches(e))&&t.push(s),s=s.previousElementSibling;return t}const f=class f{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},b,t),this.settings.columnCount=Object.assign({},b.columnCount,t.columnCount),this._resizeHandler=L(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(h.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});if(h.set(e,t),f.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),t.animate){const s=t.animate===!0?"fade":t.animate;e.classList.add("mo-animate",`mo-animate-${s}`),this._observer=new IntersectionObserver(r=>{r.forEach(o=>{o.isIntersecting&&(o.target.classList.add("mo-visible"),this._observer.unobserve(o.target))})},{threshold:.1})}t.adSlots&&(t._adRealCount=0,typeof t.adSlots.onEnterViewport=="function"&&(this._adObserver=new IntersectionObserver(s=>{s.forEach(r=>{r.isIntersecting&&(this._adObserver.unobserve(r.target),t.adSlots.onEnterViewport(r.target,Number(r.target.dataset.moAdPosition)))})},{threshold:.5}))),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){f.instances.forEach(e=>{const t=e.element,s=h.get(t);s&&(s.col=s.columnCount[y()],e._setDivider(),Array.from(t.children).forEach(r=>{e._setPostPosition(r)}))})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}insertItem(e,t){const s=this.element,r=this._getData();if(!r)return;const o=this._createItemElement(e),i=Array.from(s.children).filter(n=>n.classList.contains("js-mo-item")),a=t==null?Math.floor(Math.random()*(i.length+1)):Math.max(0,Math.min(t,i.length));if(a>=i.length?s.appendChild(o):s.insertBefore(o,i[a]),o.id||(o.id="moT"+crypto.randomUUID()+"_"+a),o.classList.add("mo-item","js-mo-item"),e.fullWidth)o.classList.add("mo-fullwidth","js-mo-fullwidth");else if(r.randomFullWidth){const n=r.randomFullWidth===!0?.33:r.randomFullWidth;Math.random()<n&&o.classList.add("mo-fullwidth","js-mo-fullwidth")}return r.showBadge&&this._createBadge(o,a+1),r.showArrow&&this._createArrow(o),r.showBadge&&r.showCounterStyle==="counter"&&Array.from(s.querySelectorAll(".js-mo-item")).forEach((n,m)=>{const c=n.querySelector(".js-mo-badge");c&&(c.textContent=m+1)}),r.lastItemIdx=Array.from(s.children).length,h.set(s,r),this.refresh(),this._observeItems([o]),o.querySelectorAll("img").forEach(n=>{n.complete||n.addEventListener("load",this._resizeHandler,{once:!0})}),o}clear(){const e=this._getData();e&&(this._observer&&this._observer.disconnect(),this._adObserver&&this._adObserver.disconnect(),Array.from(this.element.children).forEach(t=>{(t.classList.contains("js-mo-item")||t.classList.contains("mo-ad-slot"))&&t.remove()}),e.lastItemIdx=0,e.adSlots&&(e._adRealCount=0))}destroy(){window.removeEventListener("resize",this._resizeHandler),this._observer&&(this._observer.disconnect(),this._observer=null),this._adObserver&&(this._adObserver.disconnect(),this._adObserver=null),Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach(e=>e.remove()),h.delete(this.element),f.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol","mo-animate","mo-animate-fade","mo-animate-slide"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth","mo-visible","mo-filtered-out"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}filterByCategory(e){const t=this._getData();t&&(t._activeFilter=e==null||e===""||e==="all"?null:String(e),h.set(this.element,t),this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))),Array.from(this.element.querySelectorAll(".js-mo-item:not(.mo-filtered-out)")).forEach(s=>{s.classList.remove("mo-inverted","js-mo-inverted","mo-offset")}),this.refresh())}_applyFilter(e){const t=this._getData();if(!t)return;const s=t._activeFilter||null;e.forEach(r=>{if(!s)r.classList.remove("mo-filtered-out");else{const o=(r.dataset.categories||"").split(/\s+/).filter(Boolean);r.classList.toggle("mo-filtered-out",!o.includes(s))}})}_getData(){return h.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[y()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const s=t.lastItemIdx,r=Array.from(e.children),o=r.slice(s);if(o.length!==0){if(o.forEach((i,a)=>{i.id||(i.id="moT"+crypto.randomUUID()+"_"+(a+s)),i.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const i=t.randomFullWidth===!0?.33:t.randomFullWidth;o.forEach(a=>{!a.classList.contains("mo-fullwidth")&&Math.random()<i&&a.classList.add("mo-fullwidth","js-mo-fullwidth")})}o.forEach((i,a)=>{t.showBadge&&this._createBadge(i,a+s+1),t.showArrow&&this._createArrow(i)}),t.lastItemIdx=r.length,h.set(e,t),this._applyFilter(o),this.refresh(),this._observeItems(o),this._injectAdSlots(o),o.forEach(i=>{i.querySelectorAll("img").forEach(a=>{a.complete||a.addEventListener("load",this._resizeHandler,{once:!0})})})}}_setPostPosition(e){if(e.classList.contains("mo-filtered-out"))return;if(e.classList.contains("mo-fullwidth")){e.classList.remove("mo-inverted","js-mo-inverted","mo-offset");return}const t=this._getLeftOrRight(e);t&&(e.classList.toggle("mo-inverted",t.lr>0),e.classList.toggle("js-mo-inverted",t.lr>0),e.classList.toggle("mo-offset",t.badge_offset>0))}_getLeftOrRight(e){if(!e)return null;const t=this._getData();if(!t)return null;const s=t.col,r=w(e,".js-mo-inverted:not(.mo-filtered-out)")[0]||null,o=w(e,".js-mo-item:not(.js-mo-inverted):not(.mo-filtered-out)")[0]||null,i=v(o),a=v(r),n=v(e);let m=0,c=0;if(s>1){i.gppu>n.o+1&&(m=1),a.gppu>i.gppu&&(m=0);let d=e.previousElementSibling;for(;d&&d.classList.contains("mo-filtered-out");)d=d.previousElementSibling;d&&Math.abs(n.o-v(d).o)<40&&(c=1)}return{lr:m,badge_offset:c}}_createBadge(e,t){const s=this._getData(),r=document.createElement("span");if(r.className="mo-badge js-mo-badge",s.showCounterStyle==="none")r.style.opacity="0";else if(s.showCounterStyle==="image"){const o=document.createElement("img");o.className="mo-badge-icon",o.alt="",o.src=e.dataset.moIcon||C,r.appendChild(o)}else r.textContent=t;e.prepend(r)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon),e.categories&&(t.dataset.categories=Array.isArray(e.categories)?e.categories.join(" "):String(e.categories));const s=document.createElement("div");s.className="mo-card";const r=this._getData();if(r&&typeof r.renderCard=="function")r.renderCard(e,s);else{if(e.banner){const i=document.createElement("div");i.className="mo-card-image";const a=document.createElement("img");if(a.className="mo-banner",a.src=e.banner,a.alt="",i.appendChild(a),e.avatar){const n=document.createElement("img");n.className="mo-avatar",n.src=e.avatar,n.alt="",i.appendChild(n)}s.appendChild(i)}const o=document.createElement("div");if(o.className="mo-card-body",e.title){const i=document.createElement("h3");i.textContent=e.title,o.appendChild(i)}if(e.meta){const i=document.createElement("p");i.className="mo-meta",i.textContent=e.meta,o.appendChild(i)}if(e.text){const i=document.createElement("p");i.textContent=e.text,o.appendChild(i)}s.appendChild(o)}return t.appendChild(s),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}_injectAdSlots(e){const t=this._getData();if(!t||!t.adSlots||!e.length)return;const{mode:s,interval:r,style:o}=t.adSlots,i=o==="fullwidth",a=this.element;let n=!1;if(s==="every_n")e.forEach((m,c)=>{if((t._adRealCount+c+1)%r===0){const d=this._createAdSlot(i);m.after(d),d.dataset.moAdPosition=String(Array.from(a.children).indexOf(d)),this._adObserver&&this._adObserver.observe(d),i&&(n=!0)}});else if(s==="random"){let m=t._adRealCount%r,c=0;for(;c<e.length;){const d=r-m,u=e.slice(c,c+d);if(u.length===d){const E=u[Math.floor(Math.random()*u.length)],g=this._createAdSlot(i);E.after(g),g.dataset.moAdPosition=String(Array.from(a.children).indexOf(g)),this._adObserver&&this._adObserver.observe(g),i&&(n=!0),m=0}else m+=u.length;c+=d}}t._adRealCount+=e.length,n&&this.refresh()}_createAdSlot(e){const t=document.createElement("li");return t.className="mo-ad-slot",e&&t.classList.add("mo-fullwidth"),t}_observeItems(e){this._observer&&e.forEach(t=>{t.classList.contains("mo-visible")||this._observer.observe(t)})}};_(f,"instances",new Set);let p=f;exports.MoTimeline=p;exports.default=p;
6
+ */const m=new WeakMap,p={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0,animate:!1,renderCard:null,adSlots:null},A="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function y(){const l=window.innerWidth;return l<600?"xs":l<992?"sm":l<1200?"md":"lg"}function C(l,e=100){let t;return(...o)=>{clearTimeout(t),t=setTimeout(()=>l(...o),e)}}const f=class f{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},p,t),this.settings.columnCount=Object.assign({},p.columnCount,t.columnCount),this._resizeHandler=C(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(m.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});if(m.set(e,t),f.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),t.animate){const o=t.animate===!0?"fade":t.animate;e.classList.add("mo-animate",`mo-animate-${o}`),this._observer=new IntersectionObserver(r=>{r.forEach(a=>{a.isIntersecting&&(a.target.classList.add("mo-visible"),this._observer.unobserve(a.target))})},{threshold:.1})}t.adSlots&&(t._adRealCount=0,typeof t.adSlots.onEnterViewport=="function"&&(this._adObserver=new IntersectionObserver(o=>{o.forEach(r=>{r.isIntersecting&&(this._adObserver.unobserve(r.target),t.adSlots.onEnterViewport(r.target,Number(r.target.dataset.moAdPosition)))})},{threshold:.5}))),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){f.instances.forEach(e=>{const t=e.element,o=m.get(t);o&&(o.col=o.columnCount[y()],e._setDivider(),e._layout())})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}insertItem(e,t){const o=this.element,r=this._getData();if(!r)return;const a=this._createItemElement(e),s=Array.from(o.children).filter(n=>n.classList.contains("js-mo-item")),i=t==null?Math.floor(Math.random()*(s.length+1)):Math.max(0,Math.min(t,s.length));if(i>=s.length?o.appendChild(a):o.insertBefore(a,s[i]),a.id||(a.id="moT"+crypto.randomUUID()+"_"+i),a.classList.add("mo-item","js-mo-item"),e.fullWidth)a.classList.add("mo-fullwidth","js-mo-fullwidth");else if(r.randomFullWidth){const n=r.randomFullWidth===!0?.33:r.randomFullWidth;Math.random()<n&&a.classList.add("mo-fullwidth","js-mo-fullwidth")}return r.showBadge&&this._createBadge(a,i+1),r.showArrow&&this._createArrow(a),r.showBadge&&r.showCounterStyle==="counter"&&Array.from(o.querySelectorAll(".js-mo-item")).forEach((n,h)=>{const d=n.querySelector(".js-mo-badge");d&&(d.textContent=h+1)}),r.lastItemIdx=Array.from(o.children).length,m.set(o,r),this.refresh(),this._observeItems([a]),a.querySelectorAll("img").forEach(n=>{n.complete||n.addEventListener("load",this._resizeHandler,{once:!0})}),a}clear(){const e=this._getData();e&&(this._observer&&this._observer.disconnect(),this._adObserver&&this._adObserver.disconnect(),Array.from(this.element.children).forEach(t=>{(t.classList.contains("js-mo-item")||t.classList.contains("mo-ad-slot"))&&t.remove()}),e.lastItemIdx=0,e.adSlots&&(e._adRealCount=0))}destroy(){window.removeEventListener("resize",this._resizeHandler),this._observer&&(this._observer.disconnect(),this._observer=null),this._adObserver&&(this._adObserver.disconnect(),this._adObserver=null),Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach(e=>e.remove()),m.delete(this.element),f.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol","mo-animate","mo-animate-fade","mo-animate-slide"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth","mo-visible","mo-filtered-out"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}filterByCategory(e){const t=this._getData();t&&(t._activeFilter=e==null||e===""||e==="all"?null:String(e),m.set(this.element,t),this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))),this.refresh())}_applyFilter(e){const t=this._getData();if(!t)return;const o=t._activeFilter||null;e.forEach(r=>{if(!o)r.classList.remove("mo-filtered-out");else{const a=(r.dataset.categories||"").split(/\s+/).filter(Boolean);r.classList.toggle("mo-filtered-out",!a.includes(o))}})}_getData(){return m.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[y()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const o=t.lastItemIdx,r=Array.from(e.children),a=r.slice(o);if(a.length!==0){if(a.forEach((s,i)=>{s.id||(s.id="moT"+crypto.randomUUID()+"_"+(i+o)),s.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const s=t.randomFullWidth===!0?.33:t.randomFullWidth;a.forEach(i=>{!i.classList.contains("mo-fullwidth")&&Math.random()<s&&i.classList.add("mo-fullwidth","js-mo-fullwidth")})}a.forEach((s,i)=>{t.showBadge&&this._createBadge(s,i+o+1),t.showArrow&&this._createArrow(s)}),t.lastItemIdx=r.length,m.set(e,t),this._applyFilter(a),this.refresh(),this._observeItems(a),this._injectAdSlots(a),a.forEach(s=>{s.querySelectorAll("img").forEach(i=>{i.complete||i.addEventListener("load",this._resizeHandler,{once:!0})})})}}_layout(){const e=this.element,t=this._getData();if(!t)return;if(t.col<=1){Array.from(e.children).forEach(s=>{s.classList.remove("mo-inverted","js-mo-inverted","mo-offset")});return}let o=0,r=0,a=-1/0;Array.from(e.children).forEach(s=>{if(s.classList.contains("mo-filtered-out"))return;if(s.classList.contains("mo-fullwidth")){s.classList.remove("mo-inverted","js-mo-inverted","mo-offset"),o=r=Math.max(o,r)+s.offsetHeight,a=-1/0;return}const i=Math.min(o,r),n=o<=r;s.classList.toggle("mo-inverted",!n),s.classList.toggle("js-mo-inverted",!n),s.classList.toggle("mo-offset",Math.abs(i-a)<40),n?o+=s.offsetHeight:r+=s.offsetHeight,a=i})}_createBadge(e,t){const o=this._getData(),r=document.createElement("span");if(r.className="mo-badge js-mo-badge",o.showCounterStyle==="none")r.style.opacity="0";else if(o.showCounterStyle==="image"){const a=document.createElement("img");a.className="mo-badge-icon",a.alt="",a.src=e.dataset.moIcon||A,r.appendChild(a)}else r.textContent=t;e.prepend(r)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon),e.categories&&(t.dataset.categories=Array.isArray(e.categories)?e.categories.join(" "):String(e.categories));const o=document.createElement("div");o.className="mo-card";const r=this._getData();if(r&&typeof r.renderCard=="function")r.renderCard(e,o);else{if(e.banner){const s=document.createElement("div");s.className="mo-card-image";const i=document.createElement("img");if(i.className="mo-banner",i.src=e.banner,i.alt="",s.appendChild(i),e.avatar){const n=document.createElement("img");n.className="mo-avatar",n.src=e.avatar,n.alt="",s.appendChild(n)}o.appendChild(s)}const a=document.createElement("div");if(a.className="mo-card-body",e.title){const s=document.createElement("h3");s.textContent=e.title,a.appendChild(s)}if(e.meta){const s=document.createElement("p");s.className="mo-meta",s.textContent=e.meta,a.appendChild(s)}if(e.text){const s=document.createElement("p");s.textContent=e.text,a.appendChild(s)}o.appendChild(a)}return t.appendChild(o),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}_injectAdSlots(e){const t=this._getData();if(!t||!t.adSlots||!e.length)return;const{mode:o,interval:r,style:a}=t.adSlots,s=a==="fullwidth",i=this.element;let n=!1;if(o==="every_n")e.forEach((h,d)=>{if((t._adRealCount+d+1)%r===0){const c=this._createAdSlot(s);h.after(c),c.dataset.moAdPosition=String(Array.from(i.children).indexOf(c)),this._adObserver&&this._adObserver.observe(c),s&&(n=!0)}});else if(o==="random"){let h=t._adRealCount%r,d=0;for(;d<e.length;){const c=r-h,u=e.slice(d,d+c);if(u.length===c){const w=u[Math.floor(Math.random()*u.length)],g=this._createAdSlot(s);w.after(g),g.dataset.moAdPosition=String(Array.from(i.children).indexOf(g)),this._adObserver&&this._adObserver.observe(g),s&&(n=!0),h=0}else h+=u.length;d+=c}}t._adRealCount+=e.length,n&&this.refresh()}_createAdSlot(e){const t=document.createElement("li");return t.className="mo-ad-slot",e&&t.classList.add("mo-fullwidth"),t}_observeItems(e){this._observer&&e.forEach(t=>{t.classList.contains("mo-visible")||this._observer.observe(t)})}};_(f,"instances",new Set);let v=f;exports.MoTimeline=v;exports.default=v;
@@ -1,3 +1,3 @@
1
1
  /*!
2
- * moTimeline v2.13.1 — CSS
2
+ * moTimeline v2.13.2 — CSS
3
3
  */:root{--mo-line-color: #dde1e7;--mo-badge-bg: #4f46e5;--mo-badge-color: #fff;--mo-badge-size: 26px;--mo-badge-font-size: 12px;--mo-arrow-color: #dde1e7}.mo-timeline{display:block;list-style:none;margin:0;padding:0;position:relative;width:100%}.mo-timeline:after{content:"";display:table;clear:both}.mo-timeline.mo-twocol:before{background-color:var(--mo-line-color);bottom:0;content:"";left:50%;margin-left:-1.5px;position:absolute;top:0;width:3px;z-index:0}.mo-timeline>.mo-item{box-sizing:border-box;display:block;float:left;position:relative;width:50%}.mo-timeline:not(.mo-twocol)>.mo-item{float:none;width:100%}.mo-timeline>.mo-item.mo-inverted{float:right}.mo-timeline.mo-twocol>.mo-item.mo-fullwidth{clear:both;float:none;width:100%}.mo-theme>.mo-item.mo-fullwidth .mo-card{margin:var(--mo-card-margin-fullwidth, .5rem)}.mo-timeline.mo-twocol>.mo-item.mo-fullwidth .mo-badge,.mo-timeline.mo-twocol>.mo-item.mo-fullwidth .mo-arrow{display:none}.mo-badge{align-items:center;background:var(--mo-badge-bg);border-radius:50%;color:var(--mo-badge-color);display:flex;font-size:var(--mo-badge-font-size);font-weight:700;height:var(--mo-badge-size);justify-content:center;width:var(--mo-badge-size);overflow:hidden;position:absolute;top:18px;z-index:2}.mo-badge .mo-badge-icon{border-radius:50%;height:100%;object-fit:cover;width:100%}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-badge{left:auto;right:calc(var(--mo-badge-size) / -2)}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-badge{left:calc(var(--mo-badge-size) / -2);right:auto}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-badge{top:calc(18px + var(--mo-badge-size) + 10px)}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-arrow{top:calc(26px + var(--mo-badge-size) + 10px)}.mo-timeline:not(.mo-twocol)>.mo-item .mo-badge{display:none}.mo-arrow{border:8px solid transparent;display:block;height:0;position:absolute;top:26px;width:0;z-index:1}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-arrow{border-left:8px solid var(--mo-arrow-color);border-right:none;left:auto;right:0}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-arrow{border-right:8px solid var(--mo-arrow-color);border-left:none;left:0;right:auto}.mo-timeline:not(.mo-twocol)>.mo-item .mo-arrow{display:none}.mo-theme{--mo-arrow-color: #fff}.mo-theme>.mo-item .mo-card{background:#fff;border-radius:var(--mo-card-border-radius, 8px);box-shadow:0 2px 14px #0000001a;margin:var(--mo-card-margin, .5rem 1.25rem .5rem .5rem);position:relative}.mo-theme>.mo-item.mo-inverted .mo-card{margin:var(--mo-card-margin-inverted, .5rem .5rem .5rem 1.25rem)}.mo-theme>.mo-item .mo-banner{border-radius:var(--mo-card-border-radius, 8px) var(--mo-card-border-radius, 8px) 0 0;display:block;max-height:240px;object-fit:cover;width:100%}.mo-theme>.mo-item .mo-card-image{overflow:visible;position:relative}.mo-theme>.mo-item .mo-avatar{border:3px solid #fff;border-radius:50%;bottom:calc(var(--mo-avatar-size, 50px) * -.44);box-shadow:0 2px 8px #0000002e;height:var(--mo-avatar-size, 50px);object-fit:cover;position:absolute;right:14px;width:var(--mo-avatar-size, 50px);z-index:1}.mo-theme>.mo-item .mo-card-body{padding:1.75rem 1rem 1rem}.mo-theme>.mo-item .mo-card-body h3{font-size:1rem;font-weight:700;margin:0 0 .3rem}.mo-theme>.mo-item .mo-card-body .mo-meta{color:#9ca3af;font-size:.75rem;margin-bottom:.5rem}.mo-theme>.mo-item .mo-card-body p{color:#6b7280;font-size:.875rem;line-height:1.55;margin:0}.mo-theme.mo-twocol>.mo-item:not(.mo-inverted) .mo-arrow{border-left-color:var(--mo-arrow-color);right:12px}.mo-theme.mo-twocol>.mo-item.mo-inverted .mo-arrow{border-right-color:var(--mo-arrow-color);left:12px}.mo-theme .mo-badge{background:#fff;border:2px solid var(--mo-line-color);box-shadow:0 2px 6px #0000001a;color:#374151}.mo-timeline.mo-animate>.mo-item{transition:opacity var(--mo-animate-duration, .5s) ease,transform var(--mo-animate-duration, .5s) ease}.mo-timeline.mo-animate-fade>.mo-item{opacity:0}.mo-timeline.mo-animate-slide>.mo-item:not(.mo-inverted){opacity:0;transform:translate(-40px)}.mo-timeline.mo-animate-slide>.mo-item.mo-inverted{opacity:0;transform:translate(40px)}.mo-timeline:not(.mo-twocol).mo-animate-slide>.mo-item{transform:translate(-40px)}.mo-timeline.mo-animate>.mo-item.mo-visible{opacity:1;transform:translate(0)}.mo-timeline>.mo-item.mo-ad-slot{min-height:100px}.mo-timeline>.mo-item.mo-filtered-out{display:none}
@@ -1,13 +1,13 @@
1
- var A = Object.defineProperty;
2
- var S = (l, e, t) => e in l ? A(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var p = (l, e, t) => S(l, typeof e != "symbol" ? e + "" : e, t);
1
+ var b = Object.defineProperty;
2
+ var E = (l, e, t) => e in l ? b(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var v = (l, e, t) => E(l, typeof e != "symbol" ? e + "" : e, t);
4
4
  /*!
5
- * moTimeline v2.13.1
5
+ * moTimeline v2.13.2
6
6
  * Responsive two-column timeline layout library
7
7
  * https://github.com/MattOpen/moTimeline
8
8
  * MIT License
9
9
  */
10
- const h = /* @__PURE__ */ new WeakMap(), _ = {
10
+ const m = /* @__PURE__ */ new WeakMap(), _ = {
11
11
  columnCount: { xs: 1, sm: 2, md: 2, lg: 2 },
12
12
  showBadge: !1,
13
13
  showArrow: !1,
@@ -27,63 +27,47 @@ const h = /* @__PURE__ */ new WeakMap(), _ = {
27
27
  // (item, cardEl) => void — custom card renderer; skips built-in HTML
28
28
  adSlots: null
29
29
  // { mode, interval, style, onEnterViewport } — see docs
30
- }, C = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";
31
- function b() {
30
+ }, A = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";
31
+ function p() {
32
32
  const l = window.innerWidth;
33
33
  return l < 600 ? "xs" : l < 992 ? "sm" : l < 1200 ? "md" : "lg";
34
34
  }
35
- function L(l, e = 100) {
35
+ function C(l, e = 100) {
36
36
  let t;
37
- return (...s) => {
38
- clearTimeout(t), t = setTimeout(() => l(...s), e);
37
+ return (...o) => {
38
+ clearTimeout(t), t = setTimeout(() => l(...o), e);
39
39
  };
40
40
  }
41
- function v(l) {
42
- return l ? {
43
- o: l.offsetTop,
44
- h: l.offsetHeight,
45
- gppu: l.offsetTop + l.offsetHeight
46
- } : { o: 0, h: 0, gppu: 0 };
47
- }
48
- function y(l, e) {
49
- const t = [];
50
- let s = l.previousElementSibling;
51
- for (; s; )
52
- (!e || s.matches(e)) && t.push(s), s = s.previousElementSibling;
53
- return t;
54
- }
55
41
  const f = class f {
56
42
  constructor(e, t = {}) {
57
43
  if (typeof e == "string" && (e = document.querySelector(e)), !e) throw new Error("moTimeline: element not found");
58
- this.element = e, this.settings = Object.assign({}, _, t), this.settings.columnCount = Object.assign({}, _.columnCount, t.columnCount), this._resizeHandler = L(() => this.refresh(), 100), this._initialized = !1, this.init();
44
+ this.element = e, this.settings = Object.assign({}, _, t), this.settings.columnCount = Object.assign({}, _.columnCount, t.columnCount), this._resizeHandler = C(() => this.refresh(), 100), this._initialized = !1, this.init();
59
45
  }
60
46
  init() {
61
47
  const e = this.element;
62
- if (h.has(e)) {
48
+ if (m.has(e)) {
63
49
  this.refresh();
64
50
  return;
65
51
  }
66
52
  const t = Object.assign({}, this.settings, { lastItemIdx: 0 });
67
- if (h.set(e, t), f.instances.add(this), e.classList.add("mo-timeline"), t.theme && e.classList.add("mo-theme"), e.style.setProperty("--mo-card-border-radius", t.cardBorderRadius), e.style.setProperty("--mo-avatar-size", t.avatarSize), e.style.setProperty("--mo-card-margin", t.cardMargin), e.style.setProperty("--mo-card-margin-inverted", t.cardMarginInverted), e.style.setProperty("--mo-card-margin-fullwidth", t.cardMarginFullWidth), t.animate) {
68
- const s = t.animate === !0 ? "fade" : t.animate;
69
- e.classList.add("mo-animate", `mo-animate-${s}`), this._observer = new IntersectionObserver((r) => {
70
- r.forEach((o) => {
71
- o.isIntersecting && (o.target.classList.add("mo-visible"), this._observer.unobserve(o.target));
53
+ if (m.set(e, t), f.instances.add(this), e.classList.add("mo-timeline"), t.theme && e.classList.add("mo-theme"), e.style.setProperty("--mo-card-border-radius", t.cardBorderRadius), e.style.setProperty("--mo-avatar-size", t.avatarSize), e.style.setProperty("--mo-card-margin", t.cardMargin), e.style.setProperty("--mo-card-margin-inverted", t.cardMarginInverted), e.style.setProperty("--mo-card-margin-fullwidth", t.cardMarginFullWidth), t.animate) {
54
+ const o = t.animate === !0 ? "fade" : t.animate;
55
+ e.classList.add("mo-animate", `mo-animate-${o}`), this._observer = new IntersectionObserver((r) => {
56
+ r.forEach((a) => {
57
+ a.isIntersecting && (a.target.classList.add("mo-visible"), this._observer.unobserve(a.target));
72
58
  });
73
59
  }, { threshold: 0.1 });
74
60
  }
75
- t.adSlots && (t._adRealCount = 0, typeof t.adSlots.onEnterViewport == "function" && (this._adObserver = new IntersectionObserver((s) => {
76
- s.forEach((r) => {
61
+ t.adSlots && (t._adRealCount = 0, typeof t.adSlots.onEnterViewport == "function" && (this._adObserver = new IntersectionObserver((o) => {
62
+ o.forEach((r) => {
77
63
  r.isIntersecting && (this._adObserver.unobserve(r.target), t.adSlots.onEnterViewport(r.target, Number(r.target.dataset.moAdPosition)));
78
64
  });
79
65
  }, { threshold: 0.5 }))), this._initialized = !0, window.addEventListener("resize", this._resizeHandler), Array.from(e.children).length > 0 && this._initItems();
80
66
  }
81
67
  refresh() {
82
68
  f.instances.forEach((e) => {
83
- const t = e.element, s = h.get(t);
84
- s && (s.col = s.columnCount[b()], e._setDivider(), Array.from(t.children).forEach((r) => {
85
- e._setPostPosition(r);
86
- }));
69
+ const t = e.element, o = m.get(t);
70
+ o && (o.col = o.columnCount[p()], e._setDivider(), e._layout());
87
71
  });
88
72
  }
89
73
  initNewItems() {
@@ -109,21 +93,21 @@ const f = class f {
109
93
  * @returns {HTMLElement} the inserted <li> element
110
94
  */
111
95
  insertItem(e, t) {
112
- const s = this.element, r = this._getData();
96
+ const o = this.element, r = this._getData();
113
97
  if (!r) return;
114
- const o = this._createItemElement(e), i = Array.from(s.children).filter((n) => n.classList.contains("js-mo-item")), a = t == null ? Math.floor(Math.random() * (i.length + 1)) : Math.max(0, Math.min(t, i.length));
115
- if (a >= i.length ? s.appendChild(o) : s.insertBefore(o, i[a]), o.id || (o.id = "moT" + crypto.randomUUID() + "_" + a), o.classList.add("mo-item", "js-mo-item"), e.fullWidth)
116
- o.classList.add("mo-fullwidth", "js-mo-fullwidth");
98
+ const a = this._createItemElement(e), s = Array.from(o.children).filter((n) => n.classList.contains("js-mo-item")), i = t == null ? Math.floor(Math.random() * (s.length + 1)) : Math.max(0, Math.min(t, s.length));
99
+ if (i >= s.length ? o.appendChild(a) : o.insertBefore(a, s[i]), a.id || (a.id = "moT" + crypto.randomUUID() + "_" + i), a.classList.add("mo-item", "js-mo-item"), e.fullWidth)
100
+ a.classList.add("mo-fullwidth", "js-mo-fullwidth");
117
101
  else if (r.randomFullWidth) {
118
102
  const n = r.randomFullWidth === !0 ? 0.33 : r.randomFullWidth;
119
- Math.random() < n && o.classList.add("mo-fullwidth", "js-mo-fullwidth");
103
+ Math.random() < n && a.classList.add("mo-fullwidth", "js-mo-fullwidth");
120
104
  }
121
- return r.showBadge && this._createBadge(o, a + 1), r.showArrow && this._createArrow(o), r.showBadge && r.showCounterStyle === "counter" && Array.from(s.querySelectorAll(".js-mo-item")).forEach((n, m) => {
122
- const c = n.querySelector(".js-mo-badge");
123
- c && (c.textContent = m + 1);
124
- }), r.lastItemIdx = Array.from(s.children).length, h.set(s, r), this.refresh(), this._observeItems([o]), o.querySelectorAll("img").forEach((n) => {
105
+ return r.showBadge && this._createBadge(a, i + 1), r.showArrow && this._createArrow(a), r.showBadge && r.showCounterStyle === "counter" && Array.from(o.querySelectorAll(".js-mo-item")).forEach((n, h) => {
106
+ const d = n.querySelector(".js-mo-badge");
107
+ d && (d.textContent = h + 1);
108
+ }), r.lastItemIdx = Array.from(o.children).length, m.set(o, r), this.refresh(), this._observeItems([a]), a.querySelectorAll("img").forEach((n) => {
125
109
  n.complete || n.addEventListener("load", this._resizeHandler, { once: !0 });
126
- }), o;
110
+ }), a;
127
111
  }
128
112
  clear() {
129
113
  const e = this._getData();
@@ -132,7 +116,7 @@ const f = class f {
132
116
  }), e.lastItemIdx = 0, e.adSlots && (e._adRealCount = 0));
133
117
  }
134
118
  destroy() {
135
- window.removeEventListener("resize", this._resizeHandler), this._observer && (this._observer.disconnect(), this._observer = null), this._adObserver && (this._adObserver.disconnect(), this._adObserver = null), Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach((e) => e.remove()), h.delete(this.element), f.instances.delete(this), this.element.style.removeProperty("--mo-card-border-radius"), this.element.style.removeProperty("--mo-avatar-size"), this.element.style.removeProperty("--mo-card-margin"), this.element.style.removeProperty("--mo-card-margin-inverted"), this.element.style.removeProperty("--mo-card-margin-fullwidth"), this.element.classList.remove("mo-timeline", "mo-theme", "mo-twocol", "mo-animate", "mo-animate-fade", "mo-animate-slide"), Array.from(this.element.children).forEach((e) => {
119
+ window.removeEventListener("resize", this._resizeHandler), this._observer && (this._observer.disconnect(), this._observer = null), this._adObserver && (this._adObserver.disconnect(), this._adObserver = null), Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach((e) => e.remove()), m.delete(this.element), f.instances.delete(this), this.element.style.removeProperty("--mo-card-border-radius"), this.element.style.removeProperty("--mo-avatar-size"), this.element.style.removeProperty("--mo-card-margin"), this.element.style.removeProperty("--mo-card-margin-inverted"), this.element.style.removeProperty("--mo-card-margin-fullwidth"), this.element.classList.remove("mo-timeline", "mo-theme", "mo-twocol", "mo-animate", "mo-animate-fade", "mo-animate-slide"), Array.from(this.element.children).forEach((e) => {
136
120
  e.classList.remove("mo-item", "js-mo-item", "mo-inverted", "js-mo-inverted", "mo-offset", "mo-fullwidth", "js-mo-fullwidth", "mo-visible", "mo-filtered-out"), e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach((t) => t.remove());
137
121
  });
138
122
  }
@@ -145,83 +129,78 @@ const f = class f {
145
129
  */
146
130
  filterByCategory(e) {
147
131
  const t = this._getData();
148
- t && (t._activeFilter = e == null || e === "" || e === "all" ? null : String(e), h.set(this.element, t), this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))), Array.from(this.element.querySelectorAll(".js-mo-item:not(.mo-filtered-out)")).forEach((s) => {
149
- s.classList.remove("mo-inverted", "js-mo-inverted", "mo-offset");
150
- }), this.refresh());
132
+ t && (t._activeFilter = e == null || e === "" || e === "all" ? null : String(e), m.set(this.element, t), this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))), this.refresh());
151
133
  }
152
134
  // ─── Private ────────────────────────────────────────────────────────────────
153
135
  _applyFilter(e) {
154
136
  const t = this._getData();
155
137
  if (!t) return;
156
- const s = t._activeFilter || null;
138
+ const o = t._activeFilter || null;
157
139
  e.forEach((r) => {
158
- if (!s)
140
+ if (!o)
159
141
  r.classList.remove("mo-filtered-out");
160
142
  else {
161
- const o = (r.dataset.categories || "").split(/\s+/).filter(Boolean);
162
- r.classList.toggle("mo-filtered-out", !o.includes(s));
143
+ const a = (r.dataset.categories || "").split(/\s+/).filter(Boolean);
144
+ r.classList.toggle("mo-filtered-out", !a.includes(o));
163
145
  }
164
146
  });
165
147
  }
166
148
  _getData() {
167
- return h.get(this.element);
149
+ return m.get(this.element);
168
150
  }
169
151
  _setDivider() {
170
152
  const e = this._getData();
171
- e && (e.col = e.columnCount[b()], this.element.classList.toggle("mo-twocol", e.col > 1));
153
+ e && (e.col = e.columnCount[p()], this.element.classList.toggle("mo-twocol", e.col > 1));
172
154
  }
173
155
  _initItems() {
174
156
  const e = this.element, t = this._getData();
175
157
  if (!t) return;
176
- const s = t.lastItemIdx, r = Array.from(e.children), o = r.slice(s);
177
- if (o.length !== 0) {
178
- if (o.forEach((i, a) => {
179
- i.id || (i.id = "moT" + crypto.randomUUID() + "_" + (a + s)), i.classList.add("mo-item", "js-mo-item");
158
+ const o = t.lastItemIdx, r = Array.from(e.children), a = r.slice(o);
159
+ if (a.length !== 0) {
160
+ if (a.forEach((s, i) => {
161
+ s.id || (s.id = "moT" + crypto.randomUUID() + "_" + (i + o)), s.classList.add("mo-item", "js-mo-item");
180
162
  }), this._setDivider(), t.randomFullWidth) {
181
- const i = t.randomFullWidth === !0 ? 0.33 : t.randomFullWidth;
182
- o.forEach((a) => {
183
- !a.classList.contains("mo-fullwidth") && Math.random() < i && a.classList.add("mo-fullwidth", "js-mo-fullwidth");
163
+ const s = t.randomFullWidth === !0 ? 0.33 : t.randomFullWidth;
164
+ a.forEach((i) => {
165
+ !i.classList.contains("mo-fullwidth") && Math.random() < s && i.classList.add("mo-fullwidth", "js-mo-fullwidth");
184
166
  });
185
167
  }
186
- o.forEach((i, a) => {
187
- t.showBadge && this._createBadge(i, a + s + 1), t.showArrow && this._createArrow(i);
188
- }), t.lastItemIdx = r.length, h.set(e, t), this._applyFilter(o), this.refresh(), this._observeItems(o), this._injectAdSlots(o), o.forEach((i) => {
189
- i.querySelectorAll("img").forEach((a) => {
190
- a.complete || a.addEventListener("load", this._resizeHandler, { once: !0 });
168
+ a.forEach((s, i) => {
169
+ t.showBadge && this._createBadge(s, i + o + 1), t.showArrow && this._createArrow(s);
170
+ }), t.lastItemIdx = r.length, m.set(e, t), this._applyFilter(a), this.refresh(), this._observeItems(a), this._injectAdSlots(a), a.forEach((s) => {
171
+ s.querySelectorAll("img").forEach((i) => {
172
+ i.complete || i.addEventListener("load", this._resizeHandler, { once: !0 });
191
173
  });
192
174
  });
193
175
  }
194
176
  }
195
- _setPostPosition(e) {
196
- if (e.classList.contains("mo-filtered-out")) return;
197
- if (e.classList.contains("mo-fullwidth")) {
198
- e.classList.remove("mo-inverted", "js-mo-inverted", "mo-offset");
177
+ _layout() {
178
+ const e = this.element, t = this._getData();
179
+ if (!t) return;
180
+ if (t.col <= 1) {
181
+ Array.from(e.children).forEach((s) => {
182
+ s.classList.remove("mo-inverted", "js-mo-inverted", "mo-offset");
183
+ });
199
184
  return;
200
185
  }
201
- const t = this._getLeftOrRight(e);
202
- t && (e.classList.toggle("mo-inverted", t.lr > 0), e.classList.toggle("js-mo-inverted", t.lr > 0), e.classList.toggle("mo-offset", t.badge_offset > 0));
203
- }
204
- _getLeftOrRight(e) {
205
- if (!e) return null;
206
- const t = this._getData();
207
- if (!t) return null;
208
- const s = t.col, r = y(e, ".js-mo-inverted:not(.mo-filtered-out)")[0] || null, o = y(e, ".js-mo-item:not(.js-mo-inverted):not(.mo-filtered-out)")[0] || null, i = v(o), a = v(r), n = v(e);
209
- let m = 0, c = 0;
210
- if (s > 1) {
211
- i.gppu > n.o + 1 && (m = 1), a.gppu > i.gppu && (m = 0);
212
- let d = e.previousElementSibling;
213
- for (; d && d.classList.contains("mo-filtered-out"); ) d = d.previousElementSibling;
214
- d && Math.abs(n.o - v(d).o) < 40 && (c = 1);
215
- }
216
- return { lr: m, badge_offset: c };
186
+ let o = 0, r = 0, a = -1 / 0;
187
+ Array.from(e.children).forEach((s) => {
188
+ if (s.classList.contains("mo-filtered-out")) return;
189
+ if (s.classList.contains("mo-fullwidth")) {
190
+ s.classList.remove("mo-inverted", "js-mo-inverted", "mo-offset"), o = r = Math.max(o, r) + s.offsetHeight, a = -1 / 0;
191
+ return;
192
+ }
193
+ const i = Math.min(o, r), n = o <= r;
194
+ s.classList.toggle("mo-inverted", !n), s.classList.toggle("js-mo-inverted", !n), s.classList.toggle("mo-offset", Math.abs(i - a) < 40), n ? o += s.offsetHeight : r += s.offsetHeight, a = i;
195
+ });
217
196
  }
218
197
  _createBadge(e, t) {
219
- const s = this._getData(), r = document.createElement("span");
220
- if (r.className = "mo-badge js-mo-badge", s.showCounterStyle === "none")
198
+ const o = this._getData(), r = document.createElement("span");
199
+ if (r.className = "mo-badge js-mo-badge", o.showCounterStyle === "none")
221
200
  r.style.opacity = "0";
222
- else if (s.showCounterStyle === "image") {
223
- const o = document.createElement("img");
224
- o.className = "mo-badge-icon", o.alt = "", o.src = e.dataset.moIcon || C, r.appendChild(o);
201
+ else if (o.showCounterStyle === "image") {
202
+ const a = document.createElement("img");
203
+ a.className = "mo-badge-icon", a.alt = "", a.src = e.dataset.moIcon || A, r.appendChild(a);
225
204
  } else
226
205
  r.textContent = t;
227
206
  e.prepend(r);
@@ -229,38 +208,38 @@ const f = class f {
229
208
  _createItemElement(e) {
230
209
  const t = document.createElement("li");
231
210
  e.icon && (t.dataset.moIcon = e.icon), e.categories && (t.dataset.categories = Array.isArray(e.categories) ? e.categories.join(" ") : String(e.categories));
232
- const s = document.createElement("div");
233
- s.className = "mo-card";
211
+ const o = document.createElement("div");
212
+ o.className = "mo-card";
234
213
  const r = this._getData();
235
214
  if (r && typeof r.renderCard == "function")
236
- r.renderCard(e, s);
215
+ r.renderCard(e, o);
237
216
  else {
238
217
  if (e.banner) {
239
- const i = document.createElement("div");
240
- i.className = "mo-card-image";
241
- const a = document.createElement("img");
242
- if (a.className = "mo-banner", a.src = e.banner, a.alt = "", i.appendChild(a), e.avatar) {
218
+ const s = document.createElement("div");
219
+ s.className = "mo-card-image";
220
+ const i = document.createElement("img");
221
+ if (i.className = "mo-banner", i.src = e.banner, i.alt = "", s.appendChild(i), e.avatar) {
243
222
  const n = document.createElement("img");
244
- n.className = "mo-avatar", n.src = e.avatar, n.alt = "", i.appendChild(n);
223
+ n.className = "mo-avatar", n.src = e.avatar, n.alt = "", s.appendChild(n);
245
224
  }
246
- s.appendChild(i);
225
+ o.appendChild(s);
247
226
  }
248
- const o = document.createElement("div");
249
- if (o.className = "mo-card-body", e.title) {
250
- const i = document.createElement("h3");
251
- i.textContent = e.title, o.appendChild(i);
227
+ const a = document.createElement("div");
228
+ if (a.className = "mo-card-body", e.title) {
229
+ const s = document.createElement("h3");
230
+ s.textContent = e.title, a.appendChild(s);
252
231
  }
253
232
  if (e.meta) {
254
- const i = document.createElement("p");
255
- i.className = "mo-meta", i.textContent = e.meta, o.appendChild(i);
233
+ const s = document.createElement("p");
234
+ s.className = "mo-meta", s.textContent = e.meta, a.appendChild(s);
256
235
  }
257
236
  if (e.text) {
258
- const i = document.createElement("p");
259
- i.textContent = e.text, o.appendChild(i);
237
+ const s = document.createElement("p");
238
+ s.textContent = e.text, a.appendChild(s);
260
239
  }
261
- s.appendChild(o);
240
+ o.appendChild(a);
262
241
  }
263
- return t.appendChild(s), t;
242
+ return t.appendChild(o), t;
264
243
  }
265
244
  _createArrow(e) {
266
245
  const t = document.createElement("span");
@@ -269,25 +248,25 @@ const f = class f {
269
248
  _injectAdSlots(e) {
270
249
  const t = this._getData();
271
250
  if (!t || !t.adSlots || !e.length) return;
272
- const { mode: s, interval: r, style: o } = t.adSlots, i = o === "fullwidth", a = this.element;
251
+ const { mode: o, interval: r, style: a } = t.adSlots, s = a === "fullwidth", i = this.element;
273
252
  let n = !1;
274
- if (s === "every_n")
275
- e.forEach((m, c) => {
276
- if ((t._adRealCount + c + 1) % r === 0) {
277
- const d = this._createAdSlot(i);
278
- m.after(d), d.dataset.moAdPosition = String(Array.from(a.children).indexOf(d)), this._adObserver && this._adObserver.observe(d), i && (n = !0);
253
+ if (o === "every_n")
254
+ e.forEach((h, d) => {
255
+ if ((t._adRealCount + d + 1) % r === 0) {
256
+ const c = this._createAdSlot(s);
257
+ h.after(c), c.dataset.moAdPosition = String(Array.from(i.children).indexOf(c)), this._adObserver && this._adObserver.observe(c), s && (n = !0);
279
258
  }
280
259
  });
281
- else if (s === "random") {
282
- let m = t._adRealCount % r, c = 0;
283
- for (; c < e.length; ) {
284
- const d = r - m, u = e.slice(c, c + d);
285
- if (u.length === d) {
286
- const E = u[Math.floor(Math.random() * u.length)], g = this._createAdSlot(i);
287
- E.after(g), g.dataset.moAdPosition = String(Array.from(a.children).indexOf(g)), this._adObserver && this._adObserver.observe(g), i && (n = !0), m = 0;
260
+ else if (o === "random") {
261
+ let h = t._adRealCount % r, d = 0;
262
+ for (; d < e.length; ) {
263
+ const c = r - h, u = e.slice(d, d + c);
264
+ if (u.length === c) {
265
+ const w = u[Math.floor(Math.random() * u.length)], g = this._createAdSlot(s);
266
+ w.after(g), g.dataset.moAdPosition = String(Array.from(i.children).indexOf(g)), this._adObserver && this._adObserver.observe(g), s && (n = !0), h = 0;
288
267
  } else
289
- m += u.length;
290
- c += d;
268
+ h += u.length;
269
+ d += c;
291
270
  }
292
271
  }
293
272
  t._adRealCount += e.length, n && this.refresh();
@@ -302,9 +281,9 @@ const f = class f {
302
281
  });
303
282
  }
304
283
  };
305
- p(f, "instances", /* @__PURE__ */ new Set());
306
- let w = f;
284
+ v(f, "instances", /* @__PURE__ */ new Set());
285
+ let y = f;
307
286
  export {
308
- w as MoTimeline,
309
- w as default
287
+ y as MoTimeline,
288
+ y as default
310
289
  };
@@ -1,6 +1,6 @@
1
- (function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.MoTimeline={}))})(this,function(c){"use strict";var L=Object.defineProperty;var I=(c,n,u)=>n in c?L(c,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[n]=u;var E=(c,n,u)=>I(c,typeof n!="symbol"?n+"":n,u);/*!
2
- * moTimeline v2.13.1
1
+ (function(d,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(d=typeof globalThis<"u"?globalThis:d||self,l(d.MoTimeline={}))})(this,function(d){"use strict";var C=Object.defineProperty;var S=(d,l,h)=>l in d?C(d,l,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[l]=h;var w=(d,l,h)=>S(d,typeof l!="symbol"?l+"":l,h);/*!
2
+ * moTimeline v2.13.2
3
3
  * Responsive two-column timeline layout library
4
4
  * https://github.com/MattOpen/moTimeline
5
5
  * MIT License
6
- */const n=new WeakMap,u={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0,animate:!1,renderCard:null,adSlots:null},A="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function y(){const m=window.innerWidth;return m<600?"xs":m<992?"sm":m<1200?"md":"lg"}function S(m,e=100){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>m(...s),e)}}function p(m){return m?{o:m.offsetTop,h:m.offsetHeight,gppu:m.offsetTop+m.offsetHeight}:{o:0,h:0,gppu:0}}function w(m,e){const t=[];let s=m.previousElementSibling;for(;s;)(!e||s.matches(e))&&t.push(s),s=s.previousElementSibling;return t}const g=class g{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},u,t),this.settings.columnCount=Object.assign({},u.columnCount,t.columnCount),this._resizeHandler=S(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(n.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});if(n.set(e,t),g.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),t.animate){const s=t.animate===!0?"fade":t.animate;e.classList.add("mo-animate",`mo-animate-${s}`),this._observer=new IntersectionObserver(r=>{r.forEach(o=>{o.isIntersecting&&(o.target.classList.add("mo-visible"),this._observer.unobserve(o.target))})},{threshold:.1})}t.adSlots&&(t._adRealCount=0,typeof t.adSlots.onEnterViewport=="function"&&(this._adObserver=new IntersectionObserver(s=>{s.forEach(r=>{r.isIntersecting&&(this._adObserver.unobserve(r.target),t.adSlots.onEnterViewport(r.target,Number(r.target.dataset.moAdPosition)))})},{threshold:.5}))),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){g.instances.forEach(e=>{const t=e.element,s=n.get(t);s&&(s.col=s.columnCount[y()],e._setDivider(),Array.from(t.children).forEach(r=>{e._setPostPosition(r)}))})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}insertItem(e,t){const s=this.element,r=this._getData();if(!r)return;const o=this._createItemElement(e),i=Array.from(s.children).filter(l=>l.classList.contains("js-mo-item")),a=t==null?Math.floor(Math.random()*(i.length+1)):Math.max(0,Math.min(t,i.length));if(a>=i.length?s.appendChild(o):s.insertBefore(o,i[a]),o.id||(o.id="moT"+crypto.randomUUID()+"_"+a),o.classList.add("mo-item","js-mo-item"),e.fullWidth)o.classList.add("mo-fullwidth","js-mo-fullwidth");else if(r.randomFullWidth){const l=r.randomFullWidth===!0?.33:r.randomFullWidth;Math.random()<l&&o.classList.add("mo-fullwidth","js-mo-fullwidth")}return r.showBadge&&this._createBadge(o,a+1),r.showArrow&&this._createArrow(o),r.showBadge&&r.showCounterStyle==="counter"&&Array.from(s.querySelectorAll(".js-mo-item")).forEach((l,f)=>{const h=l.querySelector(".js-mo-badge");h&&(h.textContent=f+1)}),r.lastItemIdx=Array.from(s.children).length,n.set(s,r),this.refresh(),this._observeItems([o]),o.querySelectorAll("img").forEach(l=>{l.complete||l.addEventListener("load",this._resizeHandler,{once:!0})}),o}clear(){const e=this._getData();e&&(this._observer&&this._observer.disconnect(),this._adObserver&&this._adObserver.disconnect(),Array.from(this.element.children).forEach(t=>{(t.classList.contains("js-mo-item")||t.classList.contains("mo-ad-slot"))&&t.remove()}),e.lastItemIdx=0,e.adSlots&&(e._adRealCount=0))}destroy(){window.removeEventListener("resize",this._resizeHandler),this._observer&&(this._observer.disconnect(),this._observer=null),this._adObserver&&(this._adObserver.disconnect(),this._adObserver=null),Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach(e=>e.remove()),n.delete(this.element),g.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol","mo-animate","mo-animate-fade","mo-animate-slide"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth","mo-visible","mo-filtered-out"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}filterByCategory(e){const t=this._getData();t&&(t._activeFilter=e==null||e===""||e==="all"?null:String(e),n.set(this.element,t),this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))),Array.from(this.element.querySelectorAll(".js-mo-item:not(.mo-filtered-out)")).forEach(s=>{s.classList.remove("mo-inverted","js-mo-inverted","mo-offset")}),this.refresh())}_applyFilter(e){const t=this._getData();if(!t)return;const s=t._activeFilter||null;e.forEach(r=>{if(!s)r.classList.remove("mo-filtered-out");else{const o=(r.dataset.categories||"").split(/\s+/).filter(Boolean);r.classList.toggle("mo-filtered-out",!o.includes(s))}})}_getData(){return n.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[y()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const s=t.lastItemIdx,r=Array.from(e.children),o=r.slice(s);if(o.length!==0){if(o.forEach((i,a)=>{i.id||(i.id="moT"+crypto.randomUUID()+"_"+(a+s)),i.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const i=t.randomFullWidth===!0?.33:t.randomFullWidth;o.forEach(a=>{!a.classList.contains("mo-fullwidth")&&Math.random()<i&&a.classList.add("mo-fullwidth","js-mo-fullwidth")})}o.forEach((i,a)=>{t.showBadge&&this._createBadge(i,a+s+1),t.showArrow&&this._createArrow(i)}),t.lastItemIdx=r.length,n.set(e,t),this._applyFilter(o),this.refresh(),this._observeItems(o),this._injectAdSlots(o),o.forEach(i=>{i.querySelectorAll("img").forEach(a=>{a.complete||a.addEventListener("load",this._resizeHandler,{once:!0})})})}}_setPostPosition(e){if(e.classList.contains("mo-filtered-out"))return;if(e.classList.contains("mo-fullwidth")){e.classList.remove("mo-inverted","js-mo-inverted","mo-offset");return}const t=this._getLeftOrRight(e);t&&(e.classList.toggle("mo-inverted",t.lr>0),e.classList.toggle("js-mo-inverted",t.lr>0),e.classList.toggle("mo-offset",t.badge_offset>0))}_getLeftOrRight(e){if(!e)return null;const t=this._getData();if(!t)return null;const s=t.col,r=w(e,".js-mo-inverted:not(.mo-filtered-out)")[0]||null,o=w(e,".js-mo-item:not(.js-mo-inverted):not(.mo-filtered-out)")[0]||null,i=p(o),a=p(r),l=p(e);let f=0,h=0;if(s>1){i.gppu>l.o+1&&(f=1),a.gppu>i.gppu&&(f=0);let d=e.previousElementSibling;for(;d&&d.classList.contains("mo-filtered-out");)d=d.previousElementSibling;d&&Math.abs(l.o-p(d).o)<40&&(h=1)}return{lr:f,badge_offset:h}}_createBadge(e,t){const s=this._getData(),r=document.createElement("span");if(r.className="mo-badge js-mo-badge",s.showCounterStyle==="none")r.style.opacity="0";else if(s.showCounterStyle==="image"){const o=document.createElement("img");o.className="mo-badge-icon",o.alt="",o.src=e.dataset.moIcon||A,r.appendChild(o)}else r.textContent=t;e.prepend(r)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon),e.categories&&(t.dataset.categories=Array.isArray(e.categories)?e.categories.join(" "):String(e.categories));const s=document.createElement("div");s.className="mo-card";const r=this._getData();if(r&&typeof r.renderCard=="function")r.renderCard(e,s);else{if(e.banner){const i=document.createElement("div");i.className="mo-card-image";const a=document.createElement("img");if(a.className="mo-banner",a.src=e.banner,a.alt="",i.appendChild(a),e.avatar){const l=document.createElement("img");l.className="mo-avatar",l.src=e.avatar,l.alt="",i.appendChild(l)}s.appendChild(i)}const o=document.createElement("div");if(o.className="mo-card-body",e.title){const i=document.createElement("h3");i.textContent=e.title,o.appendChild(i)}if(e.meta){const i=document.createElement("p");i.className="mo-meta",i.textContent=e.meta,o.appendChild(i)}if(e.text){const i=document.createElement("p");i.textContent=e.text,o.appendChild(i)}s.appendChild(o)}return t.appendChild(s),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}_injectAdSlots(e){const t=this._getData();if(!t||!t.adSlots||!e.length)return;const{mode:s,interval:r,style:o}=t.adSlots,i=o==="fullwidth",a=this.element;let l=!1;if(s==="every_n")e.forEach((f,h)=>{if((t._adRealCount+h+1)%r===0){const d=this._createAdSlot(i);f.after(d),d.dataset.moAdPosition=String(Array.from(a.children).indexOf(d)),this._adObserver&&this._adObserver.observe(d),i&&(l=!0)}});else if(s==="random"){let f=t._adRealCount%r,h=0;for(;h<e.length;){const d=r-f,_=e.slice(h,h+d);if(_.length===d){const C=_[Math.floor(Math.random()*_.length)],b=this._createAdSlot(i);C.after(b),b.dataset.moAdPosition=String(Array.from(a.children).indexOf(b)),this._adObserver&&this._adObserver.observe(b),i&&(l=!0),f=0}else f+=_.length;h+=d}}t._adRealCount+=e.length,l&&this.refresh()}_createAdSlot(e){const t=document.createElement("li");return t.className="mo-ad-slot",e&&t.classList.add("mo-fullwidth"),t}_observeItems(e){this._observer&&e.forEach(t=>{t.classList.contains("mo-visible")||this._observer.observe(t)})}};E(g,"instances",new Set);let v=g;c.MoTimeline=v,c.default=v,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
6
+ */const l=new WeakMap,h={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0,animate:!1,renderCard:null,adSlots:null},b="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function y(){const g=window.innerWidth;return g<600?"xs":g<992?"sm":g<1200?"md":"lg"}function E(g,e=100){let t;return(...o)=>{clearTimeout(t),t=setTimeout(()=>g(...o),e)}}const u=class u{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},h,t),this.settings.columnCount=Object.assign({},h.columnCount,t.columnCount),this._resizeHandler=E(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(l.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});if(l.set(e,t),u.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),t.animate){const o=t.animate===!0?"fade":t.animate;e.classList.add("mo-animate",`mo-animate-${o}`),this._observer=new IntersectionObserver(r=>{r.forEach(a=>{a.isIntersecting&&(a.target.classList.add("mo-visible"),this._observer.unobserve(a.target))})},{threshold:.1})}t.adSlots&&(t._adRealCount=0,typeof t.adSlots.onEnterViewport=="function"&&(this._adObserver=new IntersectionObserver(o=>{o.forEach(r=>{r.isIntersecting&&(this._adObserver.unobserve(r.target),t.adSlots.onEnterViewport(r.target,Number(r.target.dataset.moAdPosition)))})},{threshold:.5}))),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){u.instances.forEach(e=>{const t=e.element,o=l.get(t);o&&(o.col=o.columnCount[y()],e._setDivider(),e._layout())})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}insertItem(e,t){const o=this.element,r=this._getData();if(!r)return;const a=this._createItemElement(e),s=Array.from(o.children).filter(n=>n.classList.contains("js-mo-item")),i=t==null?Math.floor(Math.random()*(s.length+1)):Math.max(0,Math.min(t,s.length));if(i>=s.length?o.appendChild(a):o.insertBefore(a,s[i]),a.id||(a.id="moT"+crypto.randomUUID()+"_"+i),a.classList.add("mo-item","js-mo-item"),e.fullWidth)a.classList.add("mo-fullwidth","js-mo-fullwidth");else if(r.randomFullWidth){const n=r.randomFullWidth===!0?.33:r.randomFullWidth;Math.random()<n&&a.classList.add("mo-fullwidth","js-mo-fullwidth")}return r.showBadge&&this._createBadge(a,i+1),r.showArrow&&this._createArrow(a),r.showBadge&&r.showCounterStyle==="counter"&&Array.from(o.querySelectorAll(".js-mo-item")).forEach((n,f)=>{const c=n.querySelector(".js-mo-badge");c&&(c.textContent=f+1)}),r.lastItemIdx=Array.from(o.children).length,l.set(o,r),this.refresh(),this._observeItems([a]),a.querySelectorAll("img").forEach(n=>{n.complete||n.addEventListener("load",this._resizeHandler,{once:!0})}),a}clear(){const e=this._getData();e&&(this._observer&&this._observer.disconnect(),this._adObserver&&this._adObserver.disconnect(),Array.from(this.element.children).forEach(t=>{(t.classList.contains("js-mo-item")||t.classList.contains("mo-ad-slot"))&&t.remove()}),e.lastItemIdx=0,e.adSlots&&(e._adRealCount=0))}destroy(){window.removeEventListener("resize",this._resizeHandler),this._observer&&(this._observer.disconnect(),this._observer=null),this._adObserver&&(this._adObserver.disconnect(),this._adObserver=null),Array.from(this.element.querySelectorAll(".mo-ad-slot")).forEach(e=>e.remove()),l.delete(this.element),u.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol","mo-animate","mo-animate-fade","mo-animate-slide"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth","mo-visible","mo-filtered-out"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}filterByCategory(e){const t=this._getData();t&&(t._activeFilter=e==null||e===""||e==="all"?null:String(e),l.set(this.element,t),this._applyFilter(Array.from(this.element.querySelectorAll(".js-mo-item"))),this.refresh())}_applyFilter(e){const t=this._getData();if(!t)return;const o=t._activeFilter||null;e.forEach(r=>{if(!o)r.classList.remove("mo-filtered-out");else{const a=(r.dataset.categories||"").split(/\s+/).filter(Boolean);r.classList.toggle("mo-filtered-out",!a.includes(o))}})}_getData(){return l.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[y()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const o=t.lastItemIdx,r=Array.from(e.children),a=r.slice(o);if(a.length!==0){if(a.forEach((s,i)=>{s.id||(s.id="moT"+crypto.randomUUID()+"_"+(i+o)),s.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const s=t.randomFullWidth===!0?.33:t.randomFullWidth;a.forEach(i=>{!i.classList.contains("mo-fullwidth")&&Math.random()<s&&i.classList.add("mo-fullwidth","js-mo-fullwidth")})}a.forEach((s,i)=>{t.showBadge&&this._createBadge(s,i+o+1),t.showArrow&&this._createArrow(s)}),t.lastItemIdx=r.length,l.set(e,t),this._applyFilter(a),this.refresh(),this._observeItems(a),this._injectAdSlots(a),a.forEach(s=>{s.querySelectorAll("img").forEach(i=>{i.complete||i.addEventListener("load",this._resizeHandler,{once:!0})})})}}_layout(){const e=this.element,t=this._getData();if(!t)return;if(t.col<=1){Array.from(e.children).forEach(s=>{s.classList.remove("mo-inverted","js-mo-inverted","mo-offset")});return}let o=0,r=0,a=-1/0;Array.from(e.children).forEach(s=>{if(s.classList.contains("mo-filtered-out"))return;if(s.classList.contains("mo-fullwidth")){s.classList.remove("mo-inverted","js-mo-inverted","mo-offset"),o=r=Math.max(o,r)+s.offsetHeight,a=-1/0;return}const i=Math.min(o,r),n=o<=r;s.classList.toggle("mo-inverted",!n),s.classList.toggle("js-mo-inverted",!n),s.classList.toggle("mo-offset",Math.abs(i-a)<40),n?o+=s.offsetHeight:r+=s.offsetHeight,a=i})}_createBadge(e,t){const o=this._getData(),r=document.createElement("span");if(r.className="mo-badge js-mo-badge",o.showCounterStyle==="none")r.style.opacity="0";else if(o.showCounterStyle==="image"){const a=document.createElement("img");a.className="mo-badge-icon",a.alt="",a.src=e.dataset.moIcon||b,r.appendChild(a)}else r.textContent=t;e.prepend(r)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon),e.categories&&(t.dataset.categories=Array.isArray(e.categories)?e.categories.join(" "):String(e.categories));const o=document.createElement("div");o.className="mo-card";const r=this._getData();if(r&&typeof r.renderCard=="function")r.renderCard(e,o);else{if(e.banner){const s=document.createElement("div");s.className="mo-card-image";const i=document.createElement("img");if(i.className="mo-banner",i.src=e.banner,i.alt="",s.appendChild(i),e.avatar){const n=document.createElement("img");n.className="mo-avatar",n.src=e.avatar,n.alt="",s.appendChild(n)}o.appendChild(s)}const a=document.createElement("div");if(a.className="mo-card-body",e.title){const s=document.createElement("h3");s.textContent=e.title,a.appendChild(s)}if(e.meta){const s=document.createElement("p");s.className="mo-meta",s.textContent=e.meta,a.appendChild(s)}if(e.text){const s=document.createElement("p");s.textContent=e.text,a.appendChild(s)}o.appendChild(a)}return t.appendChild(o),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}_injectAdSlots(e){const t=this._getData();if(!t||!t.adSlots||!e.length)return;const{mode:o,interval:r,style:a}=t.adSlots,s=a==="fullwidth",i=this.element;let n=!1;if(o==="every_n")e.forEach((f,c)=>{if((t._adRealCount+c+1)%r===0){const m=this._createAdSlot(s);f.after(m),m.dataset.moAdPosition=String(Array.from(i.children).indexOf(m)),this._adObserver&&this._adObserver.observe(m),s&&(n=!0)}});else if(o==="random"){let f=t._adRealCount%r,c=0;for(;c<e.length;){const m=r-f,p=e.slice(c,c+m);if(p.length===m){const A=p[Math.floor(Math.random()*p.length)],_=this._createAdSlot(s);A.after(_),_.dataset.moAdPosition=String(Array.from(i.children).indexOf(_)),this._adObserver&&this._adObserver.observe(_),s&&(n=!0),f=0}else f+=p.length;c+=m}}t._adRealCount+=e.length,n&&this.refresh()}_createAdSlot(e){const t=document.createElement("li");return t.className="mo-ad-slot",e&&t.classList.add("mo-fullwidth"),t}_observeItems(e){this._observer&&e.forEach(t=>{t.classList.contains("mo-visible")||this._observer.observe(t)})}};w(u,"instances",new Set);let v=u;d.MoTimeline=v,d.default=v,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motimeline",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
4
4
  "description": "Responsive two-column timeline layout library. Plain JavaScript, no dependencies.",
5
5
  "main": "./dist/moTimeline.cjs",
6
6
  "module": "./dist/moTimeline.js",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * moTimeline v2.13.1 — CSS
2
+ * moTimeline v2.13.2 — CSS
3
3
  */
4
4
 
5
5
  /* ── CSS custom properties (easy override) ─────────────────── */
package/src/moTimeline.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * moTimeline v2.13.1
2
+ * moTimeline v2.13.2
3
3
  * Responsive two-column timeline layout library
4
4
  * https://github.com/MattOpen/moTimeline
5
5
  * MIT License
@@ -45,24 +45,6 @@ function debounce(fn, delay = 100) {
45
45
  };
46
46
  }
47
47
 
48
- function getPosition(el) {
49
- if (!el) return { o: 0, h: 0, gppu: 0 };
50
- return {
51
- o: el.offsetTop,
52
- h: el.offsetHeight,
53
- gppu: el.offsetTop + el.offsetHeight,
54
- };
55
- }
56
-
57
- function prevAll(el, selector) {
58
- const results = [];
59
- let sibling = el.previousElementSibling;
60
- while (sibling) {
61
- if (!selector || sibling.matches(selector)) results.push(sibling);
62
- sibling = sibling.previousElementSibling;
63
- }
64
- return results;
65
- }
66
48
 
67
49
  export class MoTimeline {
68
50
  static instances = new Set();
@@ -146,10 +128,7 @@ export class MoTimeline {
146
128
 
147
129
  data.col = data.columnCount[getBreakpoint()];
148
130
  instance._setDivider();
149
-
150
- Array.from(el.children).forEach((child) => {
151
- instance._setPostPosition(child);
152
- });
131
+ instance._layout();
153
132
  });
154
133
  }
155
134
 
@@ -297,13 +276,6 @@ export class MoTimeline {
297
276
  instanceData.set(this.element, data);
298
277
 
299
278
  this._applyFilter(Array.from(this.element.querySelectorAll('.js-mo-item')));
300
-
301
- // Reset column placement on visible items only so refresh() recalculates
302
- // from scratch without stale left/right assignments interfering
303
- Array.from(this.element.querySelectorAll('.js-mo-item:not(.mo-filtered-out)')).forEach((item) => {
304
- item.classList.remove('mo-inverted', 'js-mo-inverted', 'mo-offset');
305
- });
306
-
307
279
  this.refresh();
308
280
  }
309
281
 
@@ -395,51 +367,38 @@ export class MoTimeline {
395
367
  });
396
368
  }
397
369
 
398
- _setPostPosition(el) {
399
- if (el.classList.contains('mo-filtered-out')) return;
370
+ _layout() {
371
+ const el = this.element;
372
+ const data = this._getData();
373
+ if (!data) return;
400
374
 
401
- // Full-width items span both columns — skip column assignment
402
- if (el.classList.contains('mo-fullwidth')) {
403
- el.classList.remove('mo-inverted', 'js-mo-inverted', 'mo-offset');
375
+ if (data.col <= 1) {
376
+ Array.from(el.children).forEach((child) => {
377
+ child.classList.remove('mo-inverted', 'js-mo-inverted', 'mo-offset');
378
+ });
404
379
  return;
405
380
  }
406
381
 
407
- const result = this._getLeftOrRight(el);
408
- if (!result) return;
409
-
410
- el.classList.toggle('mo-inverted', result.lr > 0);
411
- el.classList.toggle('js-mo-inverted', result.lr > 0);
412
- el.classList.toggle('mo-offset', result.badge_offset > 0);
413
- }
414
-
415
- _getLeftOrRight(el) {
416
- if (!el) return null;
417
-
418
- const data = this._getData();
419
- if (!data) return null;
420
-
421
- const col = data.col;
382
+ let leftH = 0, rightH = 0, prevStart = -Infinity;
383
+ Array.from(el.children).forEach((child) => {
384
+ if (child.classList.contains('mo-filtered-out')) return;
422
385
 
423
- const prevInverted = prevAll(el, '.js-mo-inverted:not(.mo-filtered-out)')[0] || null;
424
- const prevLeft = prevAll(el, '.js-mo-item:not(.js-mo-inverted):not(.mo-filtered-out)')[0] || null;
425
-
426
- const l = getPosition(prevLeft);
427
- const r = getPosition(prevInverted);
428
- const e = getPosition(el);
429
-
430
- let pos = 0;
431
- let bo = 0;
432
-
433
- if (col > 1) {
434
- if (l.gppu > e.o + 1) pos = 1; // +1px tolerance for offsetHeight/offsetTop rounding mismatch
435
- if (r.gppu > l.gppu) pos = 0;
436
-
437
- let prev = el.previousElementSibling;
438
- while (prev && prev.classList.contains('mo-filtered-out')) prev = prev.previousElementSibling;
439
- if (prev && Math.abs(e.o - getPosition(prev).o) < 40) bo = 1;
440
- }
386
+ if (child.classList.contains('mo-fullwidth')) {
387
+ child.classList.remove('mo-inverted', 'js-mo-inverted', 'mo-offset');
388
+ leftH = rightH = Math.max(leftH, rightH) + child.offsetHeight;
389
+ prevStart = -Infinity;
390
+ return;
391
+ }
441
392
 
442
- return { lr: pos, badge_offset: bo };
393
+ const rowStart = Math.min(leftH, rightH);
394
+ const goLeft = leftH <= rightH;
395
+ child.classList.toggle('mo-inverted', !goLeft);
396
+ child.classList.toggle('js-mo-inverted', !goLeft);
397
+ child.classList.toggle('mo-offset', Math.abs(rowStart - prevStart) < 40);
398
+ if (goLeft) leftH += child.offsetHeight;
399
+ else rightH += child.offsetHeight;
400
+ prevStart = rowStart;
401
+ });
443
402
  }
444
403
 
445
404
  _createBadge(el, idx) {