Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
*
* Behavior:
* - Shows once per browser tab session (sessionStorage). Reappears in a
* new tab/window or after the browser is fully closed and reopened,
* but not again on subsequent page loads within the same session.
* - Self-contained: all CSS is scoped under #ssdc-overlay and all class
* names are prefixed "ssdc-" so it will not collide with or leak into
* the host site's own styles.
* - Closes on: clicking the × button, clicking the dark backdrop, or
* pressing Escape. Background scroll is locked while open.
* - If a visitor is already on the same site one of the three panels
* links to (matched by base domain, any subpage counts), clicking that
* panel just closes the popover instead of navigating there again.
* - Also won't fire at all if the visitor arrived (via document.referrer)
* from any of those same three destination sites — they just came from
* there, so there's nothing to offer them.
*
* Content mirrors https://southsidesales.com/draft/ (image URLs below are
* absolute so this renders correctly no matter what site it's loaded on).
*/
(function () {
"use strict";
var STORAGE_KEY = "ssdcPopoverShown";
var BASE = "https://dev.southsidesales.com/wp-content/uploads/2026/10/southside-popup-";
// Single source of truth for the three panels: used both to render the
// markup (in buildOverlay) and to check the referrer before showing
// anything, so the two can never drift out of sync.
var PANELS = [
{
href: "https://bobcatnorthernberkshire.com/",
accent: "#f2811d",
ariaLabel: "Explore Bobcat equipment",
img: "bobcat520.jpg",
alt: "Bobcat compact track loader and excavator on a job site",
wide: false
},
{
href: "https://southsidesales.com",
accent: "#3f7d2c",
ariaLabel: "Explore lawn and garden equipment",
img: "lawncare880.jpg",
alt: "Husqvarna, Mahindra, Ariens, Gravely and Stihl lawn and snow equipment in use at a home",
wide: true
},
{
href: "https://southsidepolaris.com/",
accent: "#003087",
ariaLabel: "Explore Polaris snowmobiles",
img: "polaris520.jpg",
alt: "Polaris snowmobile jumping through snow",
wide: false
}
];
function normHost(h) {
return h.replace(/^www\./i, "").toLowerCase();
}
var DESTINATION_HOSTS = PANELS.map(function (p) {
return normHost(new URL(p.href).hostname);
});
// Only ever show once per tab session.
try {
if (sessionStorage.getItem(STORAGE_KEY)) return;
} catch (e) {
// sessionStorage unavailable (privacy mode, etc.) — fall back to
// showing every load rather than throwing.
}
// Don't show it at all if the visitor just came from one of the
// destination sites themselves.
if (document.referrer) {
try {
var refHost = normHost(new URL(document.referrer).hostname);
if (DESTINATION_HOSTS.indexOf(refHost) !== -1) return;
} catch (e) {
// Unparseable referrer — treat as "not a destination" and continue.
}
}
function markShown() {
try {
sessionStorage.setItem(STORAGE_KEY, "1");
} catch (e) {}
}
// True when `href` points at the same site the visitor is already on
// (same base domain, ignoring a "www." prefix). This intentionally
// ignores the path — a visitor on ANY subpage of, say,
// bobcatnorthernberkshire.com is still "on" that site, so the panel
// linking to it should close the popover rather than redirect them.
function isCurrentSite(href) {
try {
var target = new URL(href, location.href);
return normHost(target.hostname) === normHost(location.hostname);
} catch (e) {
return false;
}
}
function init() {
injectStyles();
var overlay = buildOverlay();
document.body.appendChild(overlay);
// Force layout, then add the "open" class so the CSS transition runs.
requestAnimationFrame(function () {
requestAnimationFrame(function () {
overlay.classList.add("ssdc-open");
});
});
var previousOverflow = document.documentElement.style.overflow;
document.documentElement.style.overflow = "hidden";
function close() {
overlay.classList.remove("ssdc-open");
document.documentElement.style.overflow = previousOverflow;
document.removeEventListener("keydown", onKeydown);
// Wait for the fade-out transition before removing from the DOM.
setTimeout(function () {
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
}, 300);
}
function onKeydown(e) {
if (e.key === "Escape" || e.keyCode === 27) close();
}
overlay.addEventListener("click", function (e) {
if (e.target === overlay) close();
});
overlay.querySelector(".ssdc-close").addEventListener("click", close);
document.addEventListener("keydown", onKeydown);
// A panel linking to the page the visitor is already on shouldn't
// navigate — just close the popover instead.
var panels = overlay.querySelectorAll(".ssdc-panel");
for (var i = 0; i < panels.length; i++) {
var panel = panels[i];
if (isCurrentSite(panel.getAttribute("href"))) {
panel.addEventListener("click", function (e) {
e.preventDefault();
close();
});
}
}
markShown();
}
function buildOverlay() {
var overlay = document.createElement("div");
overlay.id = "ssdc-overlay";
overlay.setAttribute("role", "dialog");
overlay.setAttribute("aria-modal", "true");
overlay.setAttribute("aria-label", "Shop by department");
var panelsHTML = PANELS.map(function (p) {
return (
'' +
'' +
'Explore' +
''
);
}).join("");
overlay.innerHTML =
'