1/** 2 * Divi Essential â Preloader extension (front-end runtime). 3 * 4 * Hides the overlay once BOTH the window `load` event has fired AND the 5 * minimum display time has elapsed (whichever is later), then fades out. 6 * Loaded in <head>, so the overlay element may not exist yet at parse time â 7 * DOM access is deferred to DOMContentLoaded. 8 */ 9(function () { 10 "use strict"; 11 12 var cfg = window.dnxtePreloaderData || {}; 13 var minTime = parseInt(cfg.minDisplayTime, 10) || 0; 14 var fadeDur = parseInt(cfg.fadeOutDuration, 10) || 0; 15 var onceSession = cfg.showFrequency === "once_session"; 16 var SESSION_KEY = "dnxtePreloaderShown"; 17 var SAFETY_MS = 10000; // Force-hide if `load` never fires. 18 19 var root = document.documentElement; 20 21 // "Once per session": if already shown, suppress before paint and bail. 22 if (onceSession && sessionStorage.getItem(SESSION_KEY)) { 23 var skip = document.createElement("style"); 24 skip.textContent = "#dnxte-preloader{display:none!important}"; 25 (document.head || root).appendChild(skip); 26 return; 27 } 28 29 // Lock scroll while the overlay is visible. 30 root.classList.add("dnxte-preloader-active"); 31 32 var loaded = false; 33 var minElapsed = false; 34 var done = false; 35 36 var start = Date.now(); 37 38 function getEl() { 39 return document.getElementById("dnxte-preloader"); 40 } 41 42 function unlock() { 43 root.classList.remove("dnxte-preloader-active"); 44 } 45 46 function hide() { 47 if (done) { 48 return; 49 } 50 done = true; 51 52 var el = getEl(); 53 if (!el) { 54 unlock(); 55 return; 56 } 57 58 el.classList.add("dnxte-preloader--hide"); 59 60 var remove = function () { 61 if (el && el.parentNode) { 62 el.parentNode.removeChild(el); 63 } 64 unlock(); 65 if (onceSession) { 66 try { 67 sessionStorage.setItem(SESSION_KEY, "1"); 68 } catch (e) {} 69 } 70 }; 71 72 // Remove after the fade transition (with a small buffer). 73 window.setTimeout(remove, fadeDur + 50); 74 } 75 76 function maybeHide() { 77 if (loaded && minElapsed) { 78 hide(); 79 } 80 } 81 82 // Gate 1: minimum display time. 83 window.setTimeout(function () { 84 minElapsed = true; 85 maybeHide(); 86 }, minTime); 87 88 // Gate 2: window load. 89 if (document.readyState === "complete") { 90 loaded = true; 91 maybeHide(); 92 } else { 93 window.addEventListener("load", function () { 94 loaded = true; 95 maybeHide(); 96 }); 97 } 98 99 // Safety net: never block the page indefinitely. 100 window.setTimeout(function () { 101 loaded = true; 102 minElapsed = true; 103 maybeHide(); 104 }, Math.max(SAFETY_MS, minTime + 1000)); 105 106 // --- Step-by-step loading text (milestone-based) --- 107 // Advances the text node through enabled steps as real load milestones fire, 108 // holding each step for at least `dwell` ms so it stays readable. The first 109 // step is already rendered server-side; this only handles steps 2..N. 110 var stepCfg = cfg.stepText || {}; 111 if (stepCfg.enabled && Array.isArray(stepCfg.steps) && stepCfg.steps.length > 1) { 112 initStepText(stepCfg); 113 } 114 115 function initStepText(sc) { 116 var steps = sc.steps; 117 var dwell = parseInt(sc.dwell, 10) || 0; 118 var SWAP_MS = 150; // must match the CSS fade duration. 119 120 // Which milestones have fired. `init` is true from the start. 121 var fired = { init: true, dom: false, fonts: false, load: false }; 122 123 var current = 0; // index of the currently shown step (0 = server-seeded). 124 var lastShownAt = Date.now(); 125 var stepEl = null; 126 127 function el() { 128 if (!stepEl) { 129 stepEl = document.querySelector(".dnxte-preloader__steps"); 130 } 131 return stepEl; 132 } 133 134 function show(idx) { 135 current = idx; 136 lastShownAt = Date.now(); 137 var node = el(); 138 if (!node) { 139 return; 140 } 141 node.classList.add("is-swapping"); 142 window.setTimeout(function () { 143 node.textContent = steps[idx].text; 144 node.classList.remove("is-swapping"); 145 }, SWAP_MS); 146 } 147 148 // Advance as far as the fired milestones and the dwell gate allow. 149 function tick() { 150 if (done) { 151 return; // overlay already hidden. 152 } 153 var next = current + 1; 154 if (next >= steps.length) { 155 return; 156 } 157 if (!fired[steps[next].milestone]) { 158 return; // its milestone hasn't fired yet. 159 } 160 var waited = Date.now() - lastShownAt; 161 if (waited < dwell) { 162 window.setTimeout(tick, dwell - waited); 163 return; 164 } 165 show(next); 166 window.setTimeout(tick, dwell); // the following milestone may already be ready. 167 } 168 169 function markFired(name) { 170 fired[name] = true; 171 tick(); 172 } 173 174 // DOMContentLoaded milestone. 175 if (document.readyState === "interactive" || document.readyState === "complete") { 176 fired.dom = true; 177 } else { 178 document.addEventListener("DOMContentLoaded", function () { 179 markFired("dom"); 180 }); 181 } 182 183 // Fonts milestone â guard for browsers without the Font Loading API. 184 if (document.fonts && document.fonts.ready && typeof document.fonts.ready.then === "function") { 185 document.fonts.ready.then(function () { 186 markFired("fonts"); 187 }); 188 } else { 189 fired.fonts = true; // treat as reached so it never stalls. 190 } 191 192 // window.load milestone. 193 if (document.readyState === "complete") { 194 fired.load = true; 195 } else { 196 window.addEventListener("load", function () { 197 markFired("load"); 198 }); 199 } 200 201 // Kick off (covers milestones that were already satisfied synchronously). 202 tick(); 203 } 204})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.