@finsweet/attributes-cmscss
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,1 +0,1 @@ | ||
(()=>{var p=(t,e,o)=>new Promise((i,s)=>{var m=r=>{try{n(o.next(r))}catch(c){s(c)}},a=r=>{try{n(o.throw(r))}catch(c){s(c)}},n=r=>r.done?i(r.value):Promise.resolve(r.value).then(m,a);n((o=o.apply(t,e)).next())});var u=class{static activateAlerts(){this.alertsActivated=!0}static alert(e,o){if(this.alertsActivated&&window.alert(e),o==="error")throw new Error(e)}};u.alertsActivated=!1;var A="fs-attributes",g={preventLoad:{key:`${A}-preventload`},debugMode:{key:`${A}-debug`}};var x=()=>{window.fsAttributes||(window.fsAttributes={cms:{}})},C=t=>{let{preventLoad:e,debugMode:o}=g,i=typeof(t==null?void 0:t.getAttribute(e.key))=="string";return typeof(t==null?void 0:t.getAttribute(o.key))=="string"&&u.activateAlerts(),{preventsLoad:i}},$=t=>e=>`${t}${e?`-${e}`:""}`,I=t=>(o,i,s)=>{let m=t[o],{key:a,values:n}=m,r;if(!i)return`[${a}]`;let c=n==null?void 0:n[i];if(typeof c=="string"?r=c:r=c(s&&"instanceIndex"in s?s.instanceIndex:void 0),!(s==null?void 0:s.operator))return`[${a}="${r}"]`;switch(s.operator){case"prefixed":return`[${a}^="${r}"]`;case"suffixed":return`[${a}$="${r}"]`;case"contains":return`[${a}*="${r}"]`}};var V="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmscore@1/cmscore.js";var l=()=>p(void 0,null,function*(){let{fsAttributes:t}=window;if(t.cms||(t.cms={}),t.cms.coreImport)return t.cms.coreImport;try{let e=import(V);return t.cms.coreImport=e,e}catch(e){u.alert(`${e}`,"error");return}});var f="fs-cmscss",d={element:{key:`${f}-element`,values:{list:$("list")}},pseudo:{key:`${f}-pseudo`},class:{key:`${f}-class`}},w=I(d);var{pseudo:{key:b},class:{key:M}}=d,y=t=>{for(let{element:e}of t){let{attributes:o}=e;for(let{name:i}of o){if(!i.startsWith(b))continue;let s=i.split(`${b}-`)[1],m=`${b}${s?`-${s}`:""}`,a=`${M}${s?`-${s}`:""}`,n=e.getAttribute(m),r=e.getAttribute(a);if(!n||!r)continue;let c=n.replace(/^\:/,""),T=r.replace(/^\./,""),v=e.matches(`[${m}]:${c}`);e.classList[v?"add":"remove"](T)}}};var S=()=>p(void 0,null,function*(){let t=yield l();if(!t)return[];let e=t.createCMSListInstances([w("element","list",{operator:"prefixed"})]);return yield Promise.all(e.map(k)),e}),k=t=>p(void 0,null,function*(){let{items:e}=t;y(e),t.on("renderitems",o=>y(o))});x();var{currentScript:E}=document,{preventsLoad:h}=C(E);l();h?window.fsAttributes.cmscss={init:S}:(window.Webflow||(window.Webflow=[]),window.Webflow.push(S));})(); | ||
(()=>{var p=(e,t,r)=>new Promise((n,s)=>{var m=o=>{try{i(r.next(o))}catch(c){s(c)}},a=o=>{try{i(r.throw(o))}catch(c){s(c)}},i=o=>o.done?n(o.value):Promise.resolve(o.value).then(m,a);i((r=r.apply(e,t)).next())});var u=class{static activateAlerts(){this.alertsActivated=!0}static alert(t,r){if(this.alertsActivated&&window.alert(t),r==="error")throw new Error(t)}};u.alertsActivated=!1;var A="fs-attributes",g={preventLoad:{key:`${A}-preventload`},debugMode:{key:`${A}-debug`}};var x=()=>{window.fsAttributes||(window.fsAttributes={cms:{}})},C=e=>{let{preventLoad:t,debugMode:r}=g,n=typeof(e==null?void 0:e.getAttribute(t.key))=="string";return typeof(e==null?void 0:e.getAttribute(r.key))=="string"&&u.activateAlerts(),{preventsLoad:n}},I=e=>t=>`${e}${t?`-${t}`:""}`,$=e=>(r,n,s)=>{let m=e[r],{key:a,values:i}=m,o;if(!n)return`[${a}]`;let c=i==null?void 0:i[n];if(typeof c=="string"?o=c:o=c(s&&"instanceIndex"in s?s.instanceIndex:void 0),!(s==null?void 0:s.operator))return`[${a}="${o}"]`;switch(s.operator){case"prefixed":return`[${a}^="${o}"]`;case"suffixed":return`[${a}$="${o}"]`;case"contains":return`[${a}*="${o}"]`}};var V="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmscore@1/cmscore.js";var l=()=>p(void 0,null,function*(){let{fsAttributes:e}=window;e.cms||(e.cms={});let{cms:t}=e;if(t.coreImport)return t.coreImport;try{let r=import(V);return t.coreImport=r,r.then(n=>{n&&(t.coreVersion||(t.coreVersion=n.version))}),r}catch(r){u.alert(`${r}`,"error");return}});var f="fs-cmscss",d={element:{key:`${f}-element`,values:{list:I("list")}},pseudo:{key:`${f}-pseudo`},class:{key:`${f}-class`}},w=$(d);var{pseudo:{key:b},class:{key:M}}=d,y=e=>{for(let{element:t}of e){let{attributes:r}=t;for(let{name:n}of r){if(!n.startsWith(b))continue;let s=n.split(`${b}-`)[1],m=`${b}${s?`-${s}`:""}`,a=`${M}${s?`-${s}`:""}`,i=t.getAttribute(m),o=t.getAttribute(a);if(!i||!o)continue;let c=i.replace(/^\:/,""),T=o.replace(/^\./,""),v=t.matches(`[${m}]:${c}`);t.classList[v?"add":"remove"](T)}}};var S=()=>p(void 0,null,function*(){let e=yield l();if(!e)return[];let t=e.createCMSListInstances([w("element","list",{operator:"prefixed"})]);return yield Promise.all(t.map(k)),t}),k=e=>p(void 0,null,function*(){let{items:t}=e;y(t),e.on("renderitems",r=>y(r))});x();var{currentScript:E}=document,{preventsLoad:h}=C(E);l();h?window.fsAttributes.cmscss={init:S}:(window.Webflow||(window.Webflow=[]),window.Webflow.push(S));})(); |
{ | ||
"name": "@finsweet/attributes-cmscss", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Add CSS classes to Collection Item elements based on a media query.", | ||
@@ -5,0 +5,0 @@ "main": "cmscss.js", |
3315