countdown-8.x-1.8/js/countdown.integration.min.js

js/countdown.integration.min.js
!function(t,n,e){"use strict";t.countdown=Object.assign(t.countdown||{},{instances:t.countdown&&t.countdown.instances||new WeakMap,loadedLibraries:t.countdown&&t.countdown.loadedLibraries||new Set,loaders:t.countdown&&t.countdown.loaders||{},utils:{normalizeBoolean:function(t){return 0!==t&&"0"!==t&&(1===t||"1"===t||"false"!==t&&("true"===t||!!t))},normalizeNumber:function(t,n){if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,10);return isNaN(e)?n:e}return n},detectCountdownType:function(t){return t.dataset.blockId||t.classList.contains("countdown-block")?"block":t.dataset.fieldId||t.classList.contains("countdown-field")?"field":t.dataset.viewId||t.classList.contains("countdown-view")?"view":"unknown"},resolveCountdownSettings:function(t,n,e){let o={};const i=n.countdown||{};e||(e=t.dataset.countdownLibrary||"countdown");const s={},a="data-"+e.replace("_","-")+"-";for(const n of t.attributes)if(n.name.startsWith(a)){s[n.name.replace(a,"").replace(/-/g,"_")]="true"===n.value||"false"!==n.value&&n.value}switch(this.detectCountdownType(t)){case"block":const n=t.dataset.blockId;if(i.blocks&&i.blocks[n]){const t=i.blocks[n];Object.assign(o,t.settings||{}),t.settings&&t.settings[e]&&Object.assign(o,t.settings[e])}break;case"field":const s=t.dataset.fieldId;if(i.fields&&i.fields[s]){const t=i.fields[s];Object.assign(o,t.settings||{}),t.settings&&t.settings[e]&&Object.assign(o,t.settings[e])}break;case"view":const a=t.dataset.viewId;if(i.views&&i.views[a]){const t=i.views[a];Object.assign(o,t.settings||{}),t.settings&&t.settings[e]&&Object.assign(o,t.settings[e])}}if(i.global&&i.global[e]&&(o=Object.assign({},i.global[e],o)),i.libraryConfig&&(o=Object.assign({},i.libraryConfig,o)),i.settings&&(o=Object.assign({},i.settings,o)),Object.assign(o,s),o.target_date||(o.target_date=t.dataset.countdownTarget),!o.timezone&&t.dataset.countdownTimezone&&(o.timezone=t.dataset.countdownTimezone),t.dataset.countdownSettings)try{const n=JSON.parse(t.dataset.countdownSettings);Object.assign(o,n)}catch(t){console.warn("Countdown: Failed to parse element settings",t)}return o},handleError:function(t,n,e){console.error("Countdown ["+e+"]:",n),t.dispatchEvent(new CustomEvent("countdown:error",{detail:{message:n,library:e||"unknown"}}))},dispatchEvent:function(t,n,e){t.dispatchEvent(new CustomEvent("countdown:"+n,{detail:e}))},isExpired:function(t,n){if(!t)return!0;return new Date(t+(n?" "+n:"")).getTime()<=Date.now()},showExpiredMessage:function(t,n,e){const o=n.finish_message||n.finishMessage||"Time's up!";t.innerHTML='<div class="countdown-display countdown-expired">'+o+"</div>",t.classList.add("countdown-expired"),this.dispatchEvent(t,"complete",{element:t,library:e})}},storeInstance:function(t,n){this.instances.set(t,n)},isLoaded:function(t){return this.loadedLibraries.has(t)},loadIntegration:function(t,e){if(this.isLoaded(t))return void(e&&"function"==typeof e&&e());let o="";if(n.countdown&&n.countdown.integrationBasePath)o=n.countdown.integrationBasePath;else{o=(n.countdown&&n.countdown.modulePath?n.countdown.modulePath:"/modules/contrib/countdown")+"/js/integrations"}let i="";switch(t){case"countdown":i="countdown.core.integration";break;case"flipclock":i="countdown.flipclock.integration";break;case"flipdown":i="countdown.flipdown.integration";break;case"flip":i="countdown.flip.integration";break;case"tick":i="countdown.tick.integration";break;default:return void console.warn("Countdown: Unknown library",t)}const s=o+"/"+i+(null!==document.querySelector('script[src*="countdown.integration.min.js"]')?".min.js":".js"),a=document.createElement("script");a.src=s,a.async=!0,a.defer=!0,a.onload=()=>{this.loadedLibraries.add(t),e&&"function"==typeof e&&e()},a.onerror=()=>{console.error("Countdown: Failed to load integration for",t,"from",s)},document.head.appendChild(a)},initialize:function(t,n){e("countdown-init",".countdown",t).forEach((t=>{t.dataset.countdownLibrary&&(t.classList.add("countdown-initialized"),this.initializeCountdown(t,n))}))},initializeCountdown:function(t,n){this.instances.has(t)&&this.stop(t);let e=t.dataset.countdownLibrary;if(!e&&t.dataset.blockId&&n.countdown&&n.countdown.blocks&&n.countdown.blocks[t.dataset.blockId]&&(e=n.countdown.blocks[t.dataset.blockId].library),!e&&t.dataset.fieldId&&n.countdown&&n.countdown.fields&&n.countdown.fields[t.dataset.fieldId]&&(e=n.countdown.fields[t.dataset.fieldId].library),!e&&n.countdown&&n.countdown.activeLibrary&&(e=n.countdown.activeLibrary),!e)return console.warn("Countdown: No library specified for element",t),void t.dispatchEvent(new CustomEvent("countdown:error",{detail:{message:"No countdown library specified"}}));t.addEventListener("countdown:initialized",(function(t){const n=t.target.querySelector(".countdown-display .countdown-loading");n&&n.remove()}),{once:!0}),t.addEventListener("countdown:error",(function(t){const n=t.target.querySelector(".countdown-display .countdown-loading");n&&(n.textContent=t.detail&&t.detail.message?t.detail.message:"Failed to initialize countdown.")}),{once:!0}),this.isLoaded(e)?this.loaders[e]&&this.loaders[e](t,n):this.loadIntegration(e,(()=>{this.loaders[e]&&this.loaders[e](t,n)}))},stop:function(t){const n=this.instances.get(t);n&&(n.stop&&"function"==typeof n.stop&&n.stop(),n.instance&&n.instance.stop&&n.instance.stop(),n.counter&&n.counter.stop&&n.counter.stop(),t.dataset.countdownInterval&&(clearInterval(t.dataset.countdownInterval),delete t.dataset.countdownInterval),this.instances.delete(t),t.classList.remove("countdown-initialized"),t.dispatchEvent(new CustomEvent("countdown:stopped",{detail:{element:t}})))},registerLoader:function(t,n){this.loaders[t]=n}}),t.behaviors.countdownIntegration={attach:function(n,e){t.countdown.initialize(n,e)},detach:function(n,e,o){if("unload"===o){n.querySelectorAll(".countdown.countdown-initialized").forEach((function(n){t.countdown.stop(n)}))}}}}(Drupal,drupalSettings,once);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc