PluginProbe
Countdown Timer Block – build urgency for events and launches / 1.1.0
Countdown Timer Block – build urgency for events and launches v1.1.0
1.3.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 32 releases
countdown-time / dist / script.js

script.js in Countdown Timer Block – build urgency for events and launches 1.1.0, at dist/script.js

2 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){"use strict";var t=wp.element,e=wp.i18n,n=wp.blockEditor,o=(0,t.forwardRef)((function(t,o){var a=t.is,c=t.boxClass,r=t.isLabels,l=t.label,i=t.isBackend,s=void 0!==i&&i,u=t.onChange;return a&&wp.element.createElement("div",{className:"countdownItem ".concat(c)},wp.element.createElement("span",{className:"digit",ref:o},"00"),r&&wp.element.createElement(wp.element.Fragment,null,s?wp.element.createElement(n.RichText,{className:"label",tagName:"span",value:l,onChange:function(t){return u(t)},placeholder:(0,e.__)("Label","countdown-time")}):l&&wp.element.createElement("label",{className:"label"},l)))}));function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var o,a,c=[],r=!0,l=!1;try{for(n=n.call(t);!(r=(o=n.next()).done)&&(c.push(o.value),!e||c.length!==e);r=!0);}catch(t){l=!0,a=t}finally{try{r||null==n.return||n.return()}finally{if(l)throw a}}return c}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}var r=function(e){var n=e.attributes,c=e.isBackend,r=void 0!==c&&c,l=e.custom,i=n.destDate,s=n.boxIsInline,u=n.isLabels,d=n.isDays,m=n.daysLabel,b=n.isHours,f=n.hoursLabel,p=n.isMinutes,w=n.minutesLabel,g=n.isSeconds,h=n.secondsLabel,v=n.isSep,y=a((0,t.useState)(0),2),L=y[0],x=y[1];(0,t.useEffect)((function(){var t=setInterval((function(){x((function(t){return t+1}))}),1e3);return function(){return clearInterval(t)}}),[]);var C=new Date(i).getTime(),E=(0,t.useRef)(null),I=(0,t.useRef)(null),T=(0,t.useRef)(null),S=(0,t.useRef)(null);(0,t.useEffect)((function(){var t=(new Date).getTime(),e=C>t?(C-t)/1e3:0,n=Math.floor(e/86400),o=Math.floor(e%86400/3600),a=Math.floor(e%3600/60),c=Math.floor(e%60);E.current&&(E.current.innerHTML=1===n.toString().length?("0"+n).slice(-2):n),I.current&&(I.current.innerHTML=("0"+o).slice(-2)),T.current&&(T.current.innerHTML=("0"+a).slice(-2)),S.current&&(S.current.innerHTML=("0"+c).slice(-2))}),[C,L,E.current,I.current,T.current,S.current]);var k="".concat(s?"inline":"");return wp.element.createElement("div",{className:"countdownItems"},wp.element.createElement(o,{ref:E,is:d,boxClass:"countdownDays ".concat(k),isLabels:u,label:m,isBackend:r,onChange:function(t){return r&&l.setAttributes({daysLabel:t})}}),v&&d&&(b||p||g)&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(o,{ref:I,is:b,boxClass:"countdownHours ".concat(k),isLabels:u,label:f,isBackend:r,onChange:function(t){return r&&l.setAttributes({hoursLabel:t})}}),v&&b&&(p||g)&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(o,{ref:T,is:p,boxClass:"countdownMinutes ".concat(k),isLabels:u,label:w,isBackend:r,onChange:function(t){return r&&l.setAttributes({minutesLabel:t})}}),v&&p&&g&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(o,{ref:S,is:g,boxClass:"countdownSeconds ".concat(k),isLabels:u,label:h,isBackend:r,onChange:function(t){return r&&l.setAttributes({secondsLabel:t})}}))},l=function(t){var e=t.attributes,n=t.clientId,o=e.boxPosition,a=e.width,c=e.background,r=e.padding,l=e.shadow,i=e.alignment,s=e.boxBG,u=e.boxWidth,d=e.boxHeight,m=e.boxSpace,b=e.boxBorder,f=e.boxShadow,p=e.digitTypo,w=e.digitColor,g=e.labelTypo,h=e.labelColor,v=e.sepType,y=e.sepSize,L=e.sepColor,x=function(t,e){return void 0===t?e:t};return wp.element.createElement("style",{dangerouslySetInnerHTML:{__html:"\n\t\t".concat(null!=p&&p.googleFontLink?"@import url(".concat(null==p?void 0:p.googleFontLink,")"):"","\n\t\t").concat(null!=g&&g.googleFontLink?"@import url(".concat(null==g?void 0:g.googleFontLink,")"):"","\n\n\t\t#ctbCountdownTime-").concat(n,"{\n\t\t\talign-items: ").concat(i,";\n\t\t\tjustify-content: ").concat(i,";\n\t\t}\n\t\t#ctbCountdownTime-").concat(n," .countdownItems{\n\t\t\twidth: ").concat("0px"===a||"0%"===a||"0em"===a?"auto":a,";\n\t\t\t").concat((null==c?void 0:c.styles)||"background-color: #0000;","\n\t\t\tpadding: ").concat((null==r?void 0:r.styles)||"10px 15px",";\n\t\t\tbox-shadow: ").concat((null==l?void 0:l.styles)||"none",";\n\t\t\tjustify-content: ").concat(o,";\n\t\t}\n\t\t#ctbCountdownTime-").concat(n," .countdownItems .countdownItem{\n\t\t\t").concat((null==s?void 0:s.styles)||"background-image: linear-gradient(135deg, #4527a4, #8344c5);","\n\t\t\twidth: ").concat(u,";\n\t\t\theight: ").concat(d,";\n\t\t\tmargin-left: calc(").concat(m," / 2);\n\t\t\tmargin-right: calc(").concat(m," / 2);\n\t\t\t").concat(x(null==b?void 0:b.styles,"border-radius: 5%;"),"\n\t\t\tbox-shadow: ").concat((null==f?void 0:f.styles)||"none",";\n\t\t}\n\t\t@media screen and (max-width: 575px){ #ctbCountdownTime-").concat(n," .countdownItems .countdownItem{\n\t\t\tmargin-top: calc(").concat(m," / 2);\n\t\t\tmargin-bottom: calc(").concat(m," / 2);\n\t\t} }\n\n\t\t#ctbCountdownTime-").concat(n," .countdownItems .separator::before{\n\t\t\tcontent: '").concat(v,"';\n\t\t\tfont-size: ").concat(y,"px;\n\t\t\tcolor: ").concat(L,";\n\t\t}\n\t\t#ctbCountdownTime-").concat(n," .countdownItems .countdownItem .digit{\n\t\t\tcolor: ").concat(w,";\n\t\t\t").concat(x(null==p?void 0:p.styles,"font-size: 48px;"),"\n\t\t}\n\t\t#ctbCountdownTime-").concat(n," .countdownItems .countdownItem .label{\n\t\t\tcolor: ").concat(h,";\n\t\t\t").concat(x(null==g?void 0:g.styles,"font-size: 18px;"),"\n\t\t}\n\t\t").replace(/\s+/g," ")}})};document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll(".wp-block-ctb-countdown-time").forEach((function(e){var n=JSON.parse(e.dataset.attributes);(0,t.render)(wp.element.createElement(wp.element.Fragment,null,wp.element.createElement(l,{attributes:n,clientId:n.cId}),wp.element.createElement(r,{attributes:n})),e),null==e||e.removeAttribute("data-attributes")}))}))}();
2 //# sourceMappingURL=script.js.map