/* =========================================================
LGT Campaign Bar (BALK 3) — v2 (STICKY FIXED)
Loaded as
So this file MUST be valid JavaScript (even if extension is .html).
Behaviour:
- Height 30px, mobile-only
- Inserted AFTER black USP bar (.lgt-uspbar-top)
- Sticky logic:
* If USP clone (.lgt-uspbar-clone) is visible (opacity > 0.02) -> show fixed bar under it
* Else if scrollY >= 49 -> show fixed bar under white header
* Else -> show flow bar in-page
- Close: hides for 30 minutes (sessionStorage)
- If no active campaign -> bar does not exist (display none + css var 0)
========================================================= */
(function(){
"use strict";
var MQ = window.matchMedia && window.matchMedia("(max-width: 768px)");
function isMobile(){ return MQ ? MQ.matches : (window.innerWidth <= 768); }
// Some themes scroll inside a container (overflow:auto) instead of window.
// We detect the real scroller so sticky logic works everywhere.
var scroller = null;
var scrollIsWindow = true;
function pickScroller(){
var candidates = [
document.querySelector("main#maincontent"),
document.querySelector("main.page-main"),
document.querySelector(".page-wrapper"),
document.scrollingElement || document.documentElement
].filter(Boolean);
for (var i=0;i el.clientHeight + 2);
if (canScroll && tall){
scroller = el;
scrollIsWindow = false;
return;
}
}
scroller = window;
scrollIsWindow = true;
}
function getScrollTop(){
if (scrollIsWindow) return window.pageYOffset || 0;
return scroller ? (scroller.scrollTop || 0) : 0;
}
var CLOSE_KEY_UNTIL = "lgt_campaignbar_closed_until";
var CLOSE_MS = 30 * 60 * 1000;
// --------- Campaign data (edit here) ----------
// All CTAs go to /cadeautips as requested
// textHtml can contain emoji + simple inline SVG.
var campaigns = [
{ id:"valentijn-2026", start:"2026-01-25T00:00:00+01:00", end:"2026-02-14T23:59:59+01:00", bg:"#ffd1dc", fg:"#333",
textHtml:"❤️ Valentijn: verras je lief — cadeautips →" },
{ id:"valentijn-2027", start:"2027-01-25T00:00:00+01:00", end:"2027-02-14T23:59:59+01:00", bg:"#ffd1dc", fg:"#333",
textHtml:"❤️ Valentijn: verras je lief — cadeautips →" },
{ id:"valentijn-2028", start:"2028-01-25T00:00:00+01:00", end:"2028-02-14T23:59:59+01:00", bg:"#ffd1dc", fg:"#333",
textHtml:"❤️ Valentijn: verras je lief — cadeautips →" },
{ id:"lente-2026", start:"2026-03-20T00:00:00+01:00", end:"2026-03-24T23:59:59+01:00", bg:"#e8fff1", fg:"#14532d",
textHtml:"🌸 Lente Deal: 10% korting — code: " },
{ id:"lente-2027", start:"2027-03-20T00:00:00+01:00", end:"2027-03-24T23:59:59+01:00", bg:"#e8fff1", fg:"#14532d",
textHtml:"🌸 Lente Deal: 10% korting — code: " },
{ id:"lente-2028", start:"2028-03-20T00:00:00+01:00", end:"2028-03-24T23:59:59+01:00", bg:"#e8fff1", fg:"#14532d",
textHtml:"🌸 Lente Deal: 10% korting — code: " },
{ id:"pasen-2026", start:"2026-04-02T00:00:00+02:00", end:"2026-04-06T23:59:59+02:00", bg:"#fff7cc", fg:"#5a2a00",
textHtml:"🐣 Paas-cadeautips: Dames → | Heren →" },
{ id:"pasen-2027", start:"2027-03-25T00:00:00+01:00", end:"2027-03-29T23:59:59+02:00", bg:"#fff7cc", fg:"#5a2a00",
textHtml:"🐣 Paas-cadeautips: Dames → | Heren →" },
{ id:"pasen-2028", start:"2028-04-13T00:00:00+02:00", end:"2028-04-17T23:59:59+02:00", bg:"#fff7cc", fg:"#5a2a00",
textHtml:"🐣 Paas-cadeautips: Dames → | Heren →" },
{ id:"moederdag-2026", start:"2026-04-19T00:00:00+02:00", end:"2026-05-10T23:59:59+02:00", bg:"#ffe6f2", fg:"#333",
textHtml:"🌷 Moederdag: iets liefs voor haar — tips →" },
{ id:"moederdag-2027", start:"2027-04-18T00:00:00+02:00", end:"2027-05-09T23:59:59+02:00", bg:"#ffe6f2", fg:"#333",
textHtml:"🌷 Moederdag: iets liefs voor haar — tips →" },
{ id:"moederdag-2028", start:"2028-04-23T00:00:00+02:00", end:"2028-05-14T23:59:59+02:00", bg:"#ffe6f2", fg:"#333",
textHtml:"🌷 Moederdag: iets liefs voor haar — tips →" },
{ id:"vaderdag-2026", start:"2026-05-24T00:00:00+02:00", end:"2026-06-21T23:59:59+02:00", bg:"#d9ecff", fg:"#0b2545",
textHtml:"👔 Vaderdag: de beste cadeautjes op een rij — tips →" },
{ id:"vaderdag-2027", start:"2027-05-30T00:00:00+02:00", end:"2027-06-20T23:59:59+02:00", bg:"#d9ecff", fg:"#0b2545",
textHtml:"👔 Vaderdag: de beste cadeautjes op een rij — tips →" },
{ id:"vaderdag-2028", start:"2028-05-28T00:00:00+02:00", end:"2028-06-18T23:59:59+02:00", bg:"#d9ecff", fg:"#0b2545",
textHtml:"👔 Vaderdag: de beste cadeautjes op een rij — tips →" },
{ id:"summer-2026", start:"2026-07-08T00:00:00+02:00", end:"2026-07-12T23:59:59+02:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"☀️ Summer Sale: 10% korting — code: " },
{ id:"summer-2027", start:"2027-07-08T00:00:00+02:00", end:"2027-07-12T23:59:59+02:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"☀️ Summer Sale: 10% korting — code: " },
{ id:"summer-2028", start:"2028-07-08T00:00:00+02:00", end:"2028-07-12T23:59:59+02:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"☀️ Summer Sale: 10% korting — code: " },
{ id:"weekend-sale-1-2026", start:"2026-08-21T00:00:00+02:00", end:"2026-08-23T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-2-2026", start:"2026-09-18T00:00:00+02:00", end:"2026-09-20T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-3-2026", start:"2026-10-23T00:00:00+02:00", end:"2026-10-25T23:59:59+01:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-1-2027", start:"2027-08-20T00:00:00+02:00", end:"2027-08-22T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-2-2027", start:"2027-09-17T00:00:00+02:00", end:"2027-09-19T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-3-2027", start:"2027-10-22T00:00:00+02:00", end:"2027-10-24T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-1-2028", start:"2028-08-18T00:00:00+02:00", end:"2028-08-20T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-2-2028", start:"2028-09-15T00:00:00+02:00", end:"2028-09-17T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"weekend-sale-3-2028", start:"2028-10-20T00:00:00+02:00", end:"2028-10-22T23:59:59+02:00", bg:"#111", fg:"#fff",
textHtml:"⚡ Weekend Sale: 10% korting — code: " },
{ id:"herfst-2026", start:"2026-09-21T00:00:00+02:00", end:"2026-09-27T23:59:59+02:00", bg:"#fff4e5", fg:"#7c2d12",
textHtml:"🍂 Herfstdeals: -15% op ALLE armbanden & ringen — code: Dames armbanden → Dames ringen → Heren armbanden → Heren ringen →" },
{ id:"herfst-2027", start:"2027-09-20T00:00:00+02:00", end:"2027-09-26T23:59:59+02:00", bg:"#fff4e5", fg:"#7c2d12",
textHtml:"🍂 Herfstdeals: -15% op ALLE armbanden & ringen — code: Dames armbanden → Dames ringen → Heren armbanden → Heren ringen →" },
{ id:"herfst-2028", start:"2028-09-18T00:00:00+02:00", end:"2028-09-24T23:59:59+02:00", bg:"#fff4e5", fg:"#7c2d12",
textHtml:"🍂 Herfstdeals: -15% op ALLE armbanden & ringen — code: Dames armbanden → Dames ringen → Heren armbanden → Heren ringen →" },
{ id:"weekend-sale-winteropruiming-2026", start:"2026-01-09T00:00:00+01:00", end:"2026-01-11T23:59:59+01:00", bg:"#e6f0ff", fg:"#0b2447",
textHtml:"❄️ Winter opruiming: extra -20% op SALE — code: Shop →" },
{ id:"weekend-sale-winteropruiming-2027", start:"2027-01-08T00:00:00+01:00", end:"2027-01-10T23:59:59+01:00", bg:"#e6f0ff", fg:"#0b2447",
textHtml:"❄️ Winter opruiming: extra -20% op SALE — code: Shop →" },
{ id:"weekend-sale-winteropruiming-2028", start:"2028-01-07T00:00:00+01:00", end:"2028-01-09T23:59:59+01:00", bg:"#e6f0ff", fg:"#0b2447",
textHtml:"❄️ Winter opruiming: extra -20% op SALE — code: Shop →" },
{ id:"minimalistisch-2026", start:"2026-03-13T00:00:00+01:00", end:"2026-03-15T23:59:59+01:00", bg:"#f4f4f5", fg:"#111827",
textHtml:"✨ Minimalistisch (Dames): shop →" },
{ id:"minimalistisch-2027", start:"2027-03-12T00:00:00+01:00", end:"2027-03-14T23:59:59+01:00", bg:"#f4f4f5", fg:"#111827",
textHtml:"✨ Minimalistisch (Dames): shop →" },
{ id:"minimalistisch-2028", start:"2028-03-17T00:00:00+01:00", end:"2028-03-19T23:59:59+01:00", bg:"#f4f4f5", fg:"#111827",
textHtml:"✨ Minimalistisch (Dames): shop →" },
{ id:"koningsdag-2026", start:"2026-04-23T00:00:00+02:00", end:"2026-04-27T23:59:59+02:00", bg:"#ffedd5", fg:"#7c2d12",
textHtml:"👑 Koningsdag: -15% met code Dames armbanden → | Heren armbanden →" },
{ id:"koningsdag-2027", start:"2027-04-23T00:00:00+02:00", end:"2027-04-27T23:59:59+02:00", bg:"#ffedd5", fg:"#7c2d12",
textHtml:"👑 Koningsdag: -15% met code Dames armbanden → | Heren armbanden →" },
{ id:"koningsdag-2028", start:"2028-04-23T00:00:00+02:00", end:"2028-04-27T23:59:59+02:00", bg:"#ffedd5", fg:"#7c2d12",
textHtml:"👑 Koningsdag: -15% met code Dames armbanden → | Heren armbanden →" },
{ id:"wk-2026", start:"2026-06-11T00:00:00+02:00", end:"2026-06-18T23:59:59+02:00", bg:"#dcfce7", fg:"#14532d",
textHtml:"⚽ WK-week: -15% met code Dames → | Heren →" },
{ id:"cadeautips25-2026", start:"2026-06-22T00:00:00+02:00", end:"2026-06-28T23:59:59+02:00", bg:"#fce7f3", fg:"#831843",
textHtml:"🎁 Cadeautips < €25: Dames → | Heren →" },
{ id:"cadeautips25-2027", start:"2027-06-21T00:00:00+02:00", end:"2027-06-27T23:59:59+02:00", bg:"#fce7f3", fg:"#831843",
textHtml:"🎁 Cadeautips < €25: Dames → | Heren →" },
{ id:"cadeautips25-2028", start:"2028-06-19T00:00:00+02:00", end:"2028-06-25T23:59:59+02:00", bg:"#fce7f3", fg:"#831843",
textHtml:"🎁 Cadeautips < €25: Dames → | Heren →" },
{ id:"back2work-2026", start:"2026-08-22T00:00:00+02:00", end:"2026-08-31T23:59:59+02:00", bg:"#e0f2fe", fg:"#0c4a6e",
textHtml:"💼 Back-to-work: Dames accessoires → | Heren accessoires →" },
{ id:"back2work-2027", start:"2027-08-22T00:00:00+02:00", end:"2027-08-31T23:59:59+02:00", bg:"#e0f2fe", fg:"#0c4a6e",
textHtml:"💼 Back-to-work: Dames accessoires → | Heren accessoires →" },
{ id:"back2work-2028", start:"2028-08-22T00:00:00+02:00", end:"2028-08-31T23:59:59+02:00", bg:"#e0f2fe", fg:"#0c4a6e",
textHtml:"💼 Back-to-work: Dames accessoires → | Heren accessoires →" },
{ id:"nieuw-2026", start:"2026-09-07T00:00:00+02:00", end:"2026-09-16T23:59:59+02:00", bg:"#f0fdf4", fg:"#14532d",
textHtml:"🆕 Nieuw binnen: Dames → | Heren →" },
{ id:"nieuw-2027", start:"2027-09-06T00:00:00+02:00", end:"2027-09-15T23:59:59+02:00", bg:"#f0fdf4", fg:"#14532d",
textHtml:"🆕 Nieuw binnen: Dames → | Heren →" },
{ id:"nieuw-2028", start:"2028-09-04T00:00:00+02:00", end:"2028-09-13T23:59:59+02:00", bg:"#f0fdf4", fg:"#14532d",
textHtml:"🆕 Nieuw binnen: Dames → | Heren →" },
{ id:"weekend-sale-flash-2026", start:"2026-10-23T00:00:00+02:00", end:"2026-10-25T23:59:59+02:00", bg:"#fee2e2", fg:"#7f1d1d",
textHtml:"⚡ Weekend flash: -25% op SALE — code: Shop →" },
{ id:"weekend-sale-flash-2027", start:"2027-10-22T00:00:00+02:00", end:"2027-10-24T23:59:59+02:00", bg:"#fee2e2", fg:"#7f1d1d",
textHtml:"⚡ Weekend flash: -25% op SALE — code: Shop →" },
{ id:"weekend-sale-flash-2028", start:"2028-10-27T00:00:00+02:00", end:"2028-10-29T23:59:59+02:00", bg:"#fee2e2", fg:"#7f1d1d",
textHtml:"⚡ Weekend flash: -25% op SALE — code: Shop →" },
{ id:"singles-2026", start:"2026-11-11T00:00:00+01:00", end:"2026-11-11T23:59:59+01:00", bg:"#111827", fg:"#ffffff",
textHtml:"🖤 Singles Day: -11% — code: Shop →" },
{ id:"singles-2027", start:"2027-11-11T00:00:00+01:00", end:"2027-11-11T23:59:59+01:00", bg:"#111827", fg:"#ffffff",
textHtml:"🖤 Singles Day: -11% — code: Shop →" },
{ id:"singles-2028", start:"2028-11-11T00:00:00+01:00", end:"2028-11-11T23:59:59+01:00", bg:"#111827", fg:"#ffffff",
textHtml:"🖤 Singles Day: -11% — code: Shop →" },
{ id:"bf-2026", start:"2026-11-16T00:00:00+01:00", end:"2026-11-30T23:59:59+01:00", bg:"#111", fg:"#fff",
textHtml:"🔥 Black Friday: 15% Korting — code: " },
{ id:"bf-2027", start:"2027-11-15T00:00:00+01:00", end:"2027-11-29T23:59:59+01:00", bg:"#111", fg:"#fff",
textHtml:"🔥 Black Friday: 15% Korting — code: " },
{ id:"bf-2028", start:"2028-11-13T00:00:00+01:00", end:"2028-11-27T23:59:59+01:00", bg:"#111", fg:"#fff",
textHtml:"🔥 Black Friday: 15% Korting — code: " },
{ id:"sint-2026", start:"2026-11-12T00:00:00+01:00", end:"2026-12-05T23:59:59+01:00", bg:"#ffefc7", fg:"#5a2a00",
textHtml:"🎁 Sinterklaas: pakjesavond klaar? — tips →" },
{ id:"sint-2027", start:"2027-11-10T00:00:00+01:00", end:"2027-12-05T23:59:59+01:00", bg:"#ffefc7", fg:"#5a2a00",
textHtml:"🎁 Sinterklaas: pakjesavond klaar? — tips →" },
{ id:"sint-2028", start:"2028-11-10T00:00:00+01:00", end:"2028-12-05T23:59:59+01:00", bg:"#ffefc7", fg:"#5a2a00",
textHtml:"🎁 Sinterklaas: pakjesavond klaar? — tips →" },
{ id:"kerst-2026", start:"2026-12-06T00:00:00+01:00", end:"2026-12-31T23:59:59+01:00", bg:"#0f3d2e", fg:"#fff",
textHtml:"🎄 Kerst: feestelijk shoppen — cadeautips →" },
{ id:"kerst-2027", start:"2027-12-06T00:00:00+01:00", end:"2027-12-31T23:59:59+01:00", bg:"#0f3d2e", fg:"#fff",
textHtml:"🎄 Kerst: feestelijk shoppen — cadeautips →" },
{ id:"kerst-2028", start:"2028-12-06T00:00:00+01:00", end:"2028-12-31T23:59:59+01:00", bg:"#0f3d2e", fg:"#fff",
textHtml:"🎄 Kerst: feestelijk shoppen — cadeautips →" },
{ id:"hny-2027", start:"2027-01-01T00:00:00+01:00", end:"2027-01-07T23:59:59+01:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"✨ Happy New Year — cadeautips" },
{ id:"hny-2028", start:"2028-01-01T00:00:00+01:00", end:"2028-01-07T23:59:59+01:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"✨ Happy New Year — cadeautips" },
{ id:"hny-2029", start:"2029-01-01T00:00:00+01:00", end:"2029-01-07T23:59:59+01:00", bg:"#e6f3ff", fg:"#0b2545",
textHtml:"✨ Happy New Year — cadeautips" },
{ id:"shiptoday-2026-2028", start:"2026-01-01T00:00:00+01:00", end:"2028-12-31T23:59:59+01:00", bg:"#f5f5f5", fg:"#333",
textHtml:"⏱️ Bestel binnen 4 uur — vandaag verzonden." },
];
// Black Friday windows used to suppress Sinterklaas
var bfWindows = [
["2026-11-16T00:00:00+01:00","2026-11-30T23:59:59+01:00"],
["2027-11-15T00:00:00+01:00","2027-11-29T23:59:59+01:00"],
["2028-11-13T00:00:00+01:00","2028-11-27T23:59:59+01:00"]
];
// --------- helpers ----------
function nowMs(){ return Date.now(); }
function setCssVarHeight(px){
try{ document.documentElement.style.setProperty("--lgt-campaignbar-h", px + "px"); }catch(e){}
}
function getClosedUntil(){
try{
var v = sessionStorage.getItem(CLOSE_KEY_UNTIL);
return v ? parseInt(v,10) : 0;
}catch(e){ return 0; }
}
function isClosed(){
return false;
}
function closeFor30Min(){
return;
}
function inWindow(startIso, endIso){
var t = nowMs();
var s = new Date(startIso).getTime();
var e = new Date(endIso).getTime();
return (t >= s && t <= e);
}
function isInBlackFridayWindow(){
for (var i=0;i= 1 && day <= 5;
}
// Anonymous Gregorian algorithm (Meeus/Jones/Butcher) to compute Easter Sunday.
function easterSunday(year){
var a = year % 19;
var b = Math.floor(year / 100);
var c = year % 100;
var d = Math.floor(b / 4);
var e = b % 4;
var f = Math.floor((b + 8) / 25);
var g = Math.floor((b - f + 1) / 3);
var h = (19 * a + b - d - g + 15) % 30;
var i = Math.floor(c / 4);
var k = c % 4;
var l = (32 + 2 * e + 2 * i - h - k) % 7;
var m = Math.floor((a + 11 * h + 22 * l) / 451);
var month = Math.floor((h + l - 7 * m + 114) / 31); // 3=March, 4=April
var day = ((h + l - 7 * m + 114) % 31) + 1;
return new Date(year, month - 1, day, 12, 0, 0, 0); // noon avoids DST edge cases
}
function ymd(d){
return d.getFullYear() + "-" + pad2(d.getMonth()+1) + "-" + pad2(d.getDate());
}
function addDays(d, n){
var x = new Date(d.getTime());
x.setDate(x.getDate() + n);
return x;
}
// Dutch public holidays (most common set):
// - New Year's Day (Jan 1)
// - King's Day (Apr 27; if Sunday -> Apr 26)
// - Liberation Day (May 5) [included as holiday]
// - Easter Monday
// - Ascension Day
// - Whit Monday (Pentecost Monday)
// - Christmas Day (Dec 25) + Boxing Day (Dec 26)
function isDutchHoliday(d){
var year = d.getFullYear();
if (year < 2026 || year > 2028) return false;
var date = ymd(d);
if (date === year + "-01-01") return true; // New Year
// King's Day shift rule
var kings = new Date(year, 3, 27, 12, 0, 0, 0); // Apr 27
if (kings.getDay() === 0){ // Sunday
kings = new Date(year, 3, 26, 12, 0, 0, 0);
}
if (date === ymd(kings)) return true;
if (date === year + "-05-05") return true; // Liberation Day
var easter = easterSunday(year);
var easterMon = addDays(easter, 1);
var asc = addDays(easter, 39);
var whitMon = addDays(easter, 50);
if (date === ymd(easterMon)) return true;
if (date === ymd(asc)) return true;
if (date === ymd(whitMon)) return true;
if (date === year + "-12-25") return true;
if (date === year + "-12-26") return true;
return false;
}
function isShipTodayWindowNow(){
var now = new Date();
// Alleen ma-vr
if (!isWeekday(now)) return false;
// Niet op NL feestdagen waarop de post niet werkt
if (isDutchHoliday(now)) return false;
// Alleen tussen 12:00 en 16:00 lokale tijd
var hour = now.getHours();
var minute = now.getMinutes();
var minutesNow = hour * 60 + minute;
return minutesNow >= (12 * 60) && minutesNow < (16 * 60);
}
function msToCountdown(ms){
if (ms < 0) ms = 0;
var totalMin = Math.ceil(ms / 60000);
var hours = Math.floor(totalMin / 60);
var mins = totalMin % 60;
if (hours >= 1){
return hours + " uur en " + mins + " minuten";
}
return mins + " minuten";
}
function getNextShippingCutoff(fromDate){
var now = new Date(fromDate.getTime());
for (var i=0;i<14;i++){
var d = new Date(now.getFullYear(), now.getMonth(), now.getDate() + i, 16, 0, 0, 0);
if (!isWeekday(d)) continue;
if (isDutchHoliday(d)) continue;
if (i === 0 && now.getTime() > d.getTime()) continue;
return d;
}
return null;
}
function sameDate(a, b){
return a.getFullYear() === b.getFullYear()
&& a.getMonth() === b.getMonth()
&& a.getDate() === b.getDate();
}
function getShipLabel(cutoff, now){
var tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 12, 0, 0, 0);
if (sameDate(cutoff, now)) return "vandaag verzonden";
if (sameDate(cutoff, tomorrow)) return "morgen verzonden";
var weekdays = ["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"];
return weekdays[cutoff.getDay()] + " verzonden";
}
function shipTodayHtml(){
var now = new Date();
var cutoff = getNextShippingCutoff(now);
if (!cutoff) return "⏱️ Vandaag verzonden.";
var t = msToCountdown(cutoff.getTime() - now.getTime());
return "⏱️ Bestel binnen " + t + " — " + getShipLabel(cutoff, now) + ".";
}
function pickActiveCampaign(){
// Never show 2 campaigns at once: we collect all active ones and pick the single best by priority.
var activeList = [];
for (var i=0;i 0 ? h : 56;
}
function getUspStickyOffset(){
// If the black sticky clone is visible, campaign bar must sit UNDER it.
var uspClone = document.querySelector(".lgt-uspbar-clone");
if (!uspClone) return 0;
var cs = window.getComputedStyle(uspClone);
var op = parseFloat(cs.opacity || "0") || 0;
if (op > 0.02) return 49;
return 0;
}
function uspCloneVisible(){
var uspClone = document.querySelector(".lgt-uspbar-clone");
if (!uspClone) return false;
var cs = getComputedStyle(uspClone);
var op = parseFloat(cs.opacity || "0") || 0;
return op > 0.02;
}
function buildBar(id){
var el = document.createElement("div");
el.id = id;
el.innerHTML =
'' +
'';
return el;
}
var flowBar = null;
var fixedBar = null;
var active = null;
var raf = 0;
function ensureBars(){
ensureStyle();
if (!flowBar) flowBar = document.getElementById("header-specialday-bar") || buildBar("header-specialday-bar");
if (!fixedBar) {
fixedBar = document.getElementById("header-specialday-bar-fixed") || buildBar("header-specialday-bar-fixed");
if (!fixedBar.isConnected) document.body.appendChild(fixedBar);
}
}
function applyCampaign(c){
ensureBars();
if (!c){
active = null;
setCssVarHeight(0);
flowBar.style.display = "none";
fixedBar.style.display = "none";
return;
}
active = c;
setCssVarHeight(30);
flowBar.style.background = c.bg || "#ffd1dc";
flowBar.style.color = c.fg || "#333";
fixedBar.style.background = c.bg || "#ffd1dc";
fixedBar.style.color = c.fg || "#333";
flowBar.querySelector(".lgt-specialday-text").innerHTML = c.textHtml || "";
fixedBar.querySelector(".lgt-specialday-text").innerHTML = c.textHtml || "";
// insert flowBar after usp top if possible
var uspTop = document.querySelector(".lgt-uspbar-top");
if (uspTop && uspTop.parentNode){
uspTop.insertAdjacentElement("afterend", flowBar);
} else {
var header = document.querySelector("header.page-header") || document.querySelector(".page-header") || document.querySelector("header");
if (header) header.insertAdjacentElement("afterend", flowBar);
}
// reset display states; updatePosition() decides fixed/flow
flowBar.style.display = "flex";
fixedBar.style.display = "none";
if (isClosed()){
flowBar.classList.add("is-hidden");
fixedBar.classList.add("is-hidden");
} else {
flowBar.classList.remove("is-hidden");
fixedBar.classList.remove("is-hidden");
}
}
function updatePosition(){
if (!active) return;
if (!isMobile()){
fixedBar.style.display = "none";
return;
}
if (isClosed()){
flowBar.classList.add("is-hidden");
fixedBar.classList.add("is-hidden");
} else {
flowBar.classList.remove("is-hidden");
fixedBar.classList.remove("is-hidden");
}
var y = getScrollTop();
var headerH = getHeaderH();
if (uspCloneVisible()){
fixedBar.style.top = "calc(" + headerH + "px + 49px)";
fixedBar.style.display = "flex";
flowBar.classList.add("is-hidden"); // no layout shift
return;
}
if (y >= 49){
fixedBar.style.top = (headerH + getUspStickyOffset()) + "px";
fixedBar.style.display = "flex";
flowBar.classList.add("is-hidden");
return;
}
fixedBar.style.display = "none";
flowBar.classList.remove("is-hidden");
}
function onScroll(){
if (raf) return;
raf = requestAnimationFrame(function(){
raf = 0;
updatePosition();
});
}
function bindClose(){
document.addEventListener("click", function(e){
var btn = e.target.closest && e.target.closest("#header-specialday-bar .lgt-specialday-close, #header-specialday-bar-fixed .lgt-specialday-close");
if (!btn) return;
e.preventDefault();
e.stopPropagation();
closeFor30Min();
if (flowBar) flowBar.classList.add("is-hidden");
if (fixedBar) fixedBar.classList.add("is-hidden");
// if user stays on page, auto-restore after 30m
setTimeout(function(){
if (!isClosed()) updatePosition();
}, CLOSE_MS + 50);
}, true);
}
function bindCopyCodes(){
document.addEventListener("click", function(e){
var btn = e.target.closest && e.target.closest("#header-specialday-bar .lgt-copycode, #header-specialday-bar-fixed .lgt-copycode");
if (!btn) return;
e.preventDefault();
e.stopPropagation();
var code = (btn.getAttribute("data-code") || btn.textContent || "").trim();
if (!code) return;
function fallbackCopy(text){
try{
var ta = document.createElement("textarea");
ta.value = text;
ta.setAttribute("readonly", "");
ta.style.position = "absolute";
ta.style.left = "-9999px";
document.body.appendChild(ta);
ta.select();
document.execCommand("copy");
document.body.removeChild(ta);
return true;
}catch(err){ return false; }
}
var original = btn.textContent;
function flash(ok){
btn.textContent = ok ? "GEKOPIEERD ✓" : "NIET GELUKT";
setTimeout(function(){ btn.textContent = original; }, 1200);
}
try{
if (navigator.clipboard && window.isSecureContext){
navigator.clipboard.writeText(code).then(function(){ flash(true); }, function(){ flash(fallbackCopy(code)); });
} else {
flash(fallbackCopy(code));
}
}catch(err){
flash(false);
}
}, true);
}
function boot(){
pickScroller();
// Desktop: show the flow bar (no fixed/sticky needed)
if (!isMobile()){
ensureBars();
bindClose();
bindCopyCodes();
activeCampaignInit();
return;
}
ensureBars();
bindClose();
bindCopyCodes();
// Wait a bit for USP bar injection script to run (it creates .lgt-uspbar-top)
var stopAt = Date.now() + 4000;
(function waitForUsp(){
var uspTop = document.querySelector(".lgt-uspbar-top");
if (uspTop || Date.now() > stopAt){
activeCampaignInit();
return;
}
setTimeout(waitForUsp, 60);
})();
}
function activeCampaignInit(){
var c = pickActiveCampaign();
applyCampaign(c);
updatePosition();
// If ship-today fallback is active, refresh the countdown text periodically.
if (c && c.id && c.id.indexOf("shiptoday-") === 0){
if (window.__lgtShipTodayTimer) clearInterval(window.__lgtShipTodayTimer);
window.__lgtShipTodayTimer = setInterval(function(){
if (!active || !active.id || active.id.indexOf("shiptoday-") !== 0) return;
if (!isShipTodayWindowNow()){
return;
}
var html = shipTodayHtml();
try{
flowBar.querySelector(".lgt-specialday-text").innerHTML = html;
fixedBar.querySelector(".lgt-specialday-text").innerHTML = html;
}catch(e){}
}, 30000);
} else {
if (window.__lgtShipTodayTimer) { clearInterval(window.__lgtShipTodayTimer); window.__lgtShipTodayTimer = null; }
}
if (scrollIsWindow) if (scrollIsWindow) window.addEventListener("scroll", onScroll, {passive:true});
else if (scroller) scroller.addEventListener("scroll", onScroll, {passive:true});
else if (scroller) scroller.addEventListener("scroll", onScroll, {passive:true});
window.addEventListener("resize", onScroll, {passive:true});
}
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", boot);
else boot();
}
)();