PluginProbe
Countdown Timer Block – build urgency for events and launches / 1.1.3
Countdown Timer Block – build urgency for events and launches v1.1.3
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.3, at dist/script.js

2 lines 7.0 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=function(t){var e=t.attributes,n=t.clientId,o=e.boxPosition,a=e.width,r=e.background,c=e.padding,l=e.shadow,i=e.alignment,u=e.boxBG,s=e.boxWidth,d=e.boxHeight,m=e.boxSpace,b=e.boxBorder,f=e.boxShadow,w=e.digitTypo,p=e.digitColor,g=e.labelTypo,h=e.labelColor,v=e.sepType,y=e.sepSize,x=e.sepColor,L=function(t,e){return void 0===t?e:t};return wp.element.createElement("style",{dangerouslySetInnerHTML:{__html:"\n\t\t".concat(null!=w&&w.googleFontLink?"@import url(".concat(null==w?void 0:w.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==r?void 0:r.styles)||"background-color: #0000;","\n\t\t\tpadding: ").concat((null==c?void 0:c.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==u?void 0:u.styles)||"background-image: linear-gradient(135deg, #4527a4, #8344c5);","\n\t\t\twidth: ").concat(s,";\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(L(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(x,";\n\t\t}\n\t\t#ctbCountdownTime-").concat(n," .countdownItems .countdownItem .digit{\n\t\t\tcolor: ").concat(p,";\n\t\t\t").concat(L(null==w?void 0:w.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(L(null==g?void 0:g.styles,"font-size: 18px;"),"\n\t\t}\n\t\t").replace(/\s+/g," ")}})},n=wp.i18n,o=wp.blockEditor,a=(0,t.forwardRef)((function(t,e){var a=t.is,r=t.boxClass,c=t.isLabels,l=t.label,i=t.isBackend,u=void 0!==i&&i,s=t.onChange;return a&&wp.element.createElement("div",{className:"countdownItem ".concat(r)},wp.element.createElement("span",{className:"digit",ref:e},"00"),c&&wp.element.createElement(wp.element.Fragment,null,u?wp.element.createElement(o.RichText,{className:"label",tagName:"span",value:l,onChange:function(t){return s(t)},placeholder:(0,n.__)("Label","countdown-time")}):l&&wp.element.createElement(o.RichText.Content,{className:"label",tagName:"label",value:l})))})),r=function(t){return t>(new Date).getTime()?(t-(new Date).getTime())/1e3:0},c=function(t){return Math.floor(t/86400)},l=function(t){return Math.floor(t%86400/3600)},i=function(t){return Math.floor(t%3600/60)},u=function(t){return Math.floor(t%60)},s=function(t){return t<10?("0"+t).slice(-2):t};window.matchMedia("(max-width: 576px)"),window.matchMedia("(max-width: 768px)");function d(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,r=[],c=!0,l=!1;try{for(n=n.call(t);!(c=(o=n.next()).done)&&(r.push(o.value),!e||r.length!==e);c=!0);}catch(t){l=!0,a=t}finally{try{c||null==n.return||n.return()}finally{if(l)throw a}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return m(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 m(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 m(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 b=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=c(t),r=e?l(t):24*a+l(t),s=n?i(t):60*r+i(t),d=o?u(t):60*s+u(t),m=!(a+r+s+d>0);return{days:a,hours:r,minutes:s,seconds:d,expired:m}},f=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],c=(0,t.useState)(r(e)),l=d(c,2),i=l[0],u=l[1];return(0,t.useEffect)((function(){var t=setInterval((function(){u(r(e))}),1e3);return function(){return clearInterval(t)}}),[e]),b(i,n,o,a)},w=function(e){var n=e.attributes,o=e.isBackend,r=void 0!==o&&o,c=e.custom,l=n.destDate,i=n.boxIsInline,u=n.isLabels,d=n.isDays,m=n.daysLabel,b=n.isHours,w=n.hoursLabel,p=n.isMinutes,g=n.minutesLabel,h=n.isSeconds,v=n.secondsLabel,y=n.isSep,x=new Date(l).getTime(),L=f(x,d,b,p),C=L.days,E=L.hours,I=L.minutes,T=L.seconds,k=(0,t.useRef)(null),M=(0,t.useRef)(null),S=(0,t.useRef)(null),A=(0,t.useRef)(null);(0,t.useEffect)((function(){k.current&&(k.current.innerHTML=s(C)),M.current&&(M.current.innerHTML=s(E)),S.current&&(S.current.innerHTML=s(I)),A.current&&(A.current.innerHTML=s(T))}),[T,k.current,M.current,S.current,A.current]);var N="".concat(i?"inline":"");return wp.element.createElement("div",{className:"countdownItems"},wp.element.createElement(a,{ref:k,is:d,boxClass:"countdownDays ".concat(N),isLabels:u,label:m,isBackend:r,onChange:function(t){return r&&c.setAttributes({daysLabel:t})}}),y&&d&&(b||p||h)&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(a,{ref:M,is:b,boxClass:"countdownHours ".concat(N),isLabels:u,label:w,isBackend:r,onChange:function(t){return r&&c.setAttributes({hoursLabel:t})}}),y&&b&&(p||h)&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(a,{ref:S,is:p,boxClass:"countdownMinutes ".concat(N),isLabels:u,label:g,isBackend:r,onChange:function(t){return r&&c.setAttributes({minutesLabel:t})}}),y&&p&&h&&wp.element.createElement("span",{className:"separator"}),wp.element.createElement(a,{ref:A,is:h,boxClass:"countdownSeconds ".concat(N),isLabels:u,label:v,isBackend:r,onChange:function(t){return r&&c.setAttributes({secondsLabel:t})}}))};document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll(".wp-block-ctb-countdown-time").forEach((function(n){var o=JSON.parse(n.dataset.attributes);(0,t.render)(wp.element.createElement(wp.element.Fragment,null,wp.element.createElement(e,{attributes:o,clientId:o.cId}),wp.element.createElement(w,{attributes:o})),n),null==n||n.removeAttribute("data-attributes")}))}))}();
2 //# sourceMappingURL=script.js.map