/* EQS_MAIN_CARDS_V3 | V3 (Dec 4): Out of Stock hover message is a small white bubble with a red edge, two short lines. EQS_MAIN_CARDS_V2 | V2 (Dec 4): Lead Time lines hidden; short hover message on Out of Stock; every title fills 3 lines; every card element sits at the same height; better fractions; no repeated sizes. EQS_MAIN_CARDS_V1 | V1 (Dec 4): new product cards for the main ebsupplies.com category and search pages. PREVIEW ONLY: cards change only after visiting any page with ?eqspreview=on (remembered in this browser). Turn it back off with ?eqspreview=off. Customers see the normal site. Skips Quick Ship category pages (they have their own cards) and the list view. */ (function () { if (window.EQS_MAIN_CARDS) return; window.EQS_MAIN_CARDS = 3; document.addEventListener('click', function (e) { if (!e.target.closest || !e.target.closest('.eqm-dl.out')) document.querySelectorAll('.eqm-dl.tip-on').forEach(function (d) { d.classList.remove('tip-on'); }); }); var LIVE = false; /* set true (in a new file name) to show the new cards to everyone */ var KEY = 'eqsMainPreview'; try { var q = new URLSearchParams(location.search).get('eqspreview'); if (q === 'on') localStorage.setItem(KEY, '1'); if (q === 'off') localStorage.removeItem(KEY); if (!LIVE && localStorage.getItem(KEY) !== '1') return; } catch (e) { if (!LIVE) return; } var QS_IDS = ['1366566', '1366567', '1366568', '1366569', '1366570', '1366571', '1366572', '1366573', '1366574', '1367676', '1367679']; function quickShipPage() { var b = document.body; if (/^\/quickship/i.test(location.pathname)) return true; return QS_IDS.some(function (id) { return b.classList.contains('ex-categoryid-' + id); }); } var G = 'html.eqm-on .eqm-g'; var CSS = [ G + ' .tileparent,' + G + ' .tileparent>.tile{overflow:visible!important}', G + ' .tileparent>.tile{border:1px solid #e5e7eb!important;border-radius:14px!important;box-shadow:0 1px 3px rgba(0,0,0,.04)!important;padding:10px 12px!important;background:#fff!important;display:flex!important;flex-direction:column}', G + ' .tileparent>.tile:hover{border-color:#00843d!important;box-shadow:0 6px 18px rgba(0,0,0,.08)!important}', G + ' .tile .product-list-actions,' + G + ' .tile .live-inventory-v2-wrapper,' + G + ' .tile .product-category,' + G + ' .tile .product-compare-action,' + G + ' .tile .product-points,' + G + ' .tile .addtoquicklist-wrapper,' + G + ' .tile .addtoquicklist,' + G + ' .tile .price-area{display:none!important}', /* image */ G + ' .tile .product-tile-image{position:relative;display:block}', G + ' .tile .product-tile-image,' + G + ' .tile .product-tile-image .text-center,' + G + ' .tile .imgthumbnail{height:194px!important;overflow:visible!important}', G + ' .tile .imgthumbnail{padding:12px 16px 2px!important;box-sizing:border-box!important;display:flex!important;align-items:center;justify-content:center}', G + ' .tile .imgthumbnail .thumb-align{display:none!important}', G + ' .tile .product-tile-image img{height:auto!important;max-height:180px!important;width:auto!important;max-width:100%!important;object-fit:contain!important;transform:none!important}', '.eqm-heart{min-height:0!important;position:absolute;right:0;top:2px;width:28px;height:28px;border-radius:50%;background:transparent;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:3;opacity:.45}', '.eqm-heart svg{stroke:#9ca3af}.eqm-heart:hover{opacity:1}.eqm-heart:hover svg{stroke:#00843d}', /* footer layout: no forced heights */ G + ' .tile .footer,' + G + ' .tile .footer-wrapper{display:flex!important;flex-direction:column;flex:0 0 auto!important;height:auto!important;min-height:0!important}', G + ' .tile .footer-wrapper-description{margin-top:2px!important;height:auto!important}', /* logo + delivery row */ G + ' .tile .brand-label{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:2px!important;height:38px!important;min-height:38px!important;margin:0 0 2px!important;line-height:1!important;padding-right:6px!important;box-sizing:border-box!important;overflow:visible}', G + ' .tile .brand-label>a{display:block!important;width:80px!important;max-width:80px!important;flex:0 0 80px!important;height:36px!important;min-height:0!important;overflow:hidden;position:relative;line-height:1!important}', G + ' .tile .brand-label>a img{position:absolute;left:0;top:50%;height:36px!important;max-height:none!important;width:auto!important;max-width:none!important;transform-origin:left center}', '.eqm-dl{display:flex;flex-direction:column;align-items:flex-end;text-align:right;line-height:1.25;flex:0 1 auto;min-width:0}', '.eqm-dl b{display:inline-flex;align-items:center;gap:3px;white-space:nowrap}', '.eqm-dl.in b{font:600 11px/14px Poppins,Arial,sans-serif;color:rgb(0,132,61)}', '.eqm-dl.in b svg{width:28px;height:19px;flex:0 0 28px;stroke-width:1.8}', '.eqm-dl.out b{font:400 12px/14px Arial,sans-serif;color:#e00000}', '.eqm-dl.out b svg{width:14px;height:14px;flex:0 0 14px}', '.eqm-dl span{font:400 11px/13px Arial,sans-serif;color:#4b5563;white-space:nowrap}', /* title */ G + ' .tile .product-name{height:auto!important;min-height:0!important;margin:0 0 3px!important}', G + ' .tile .product-name a{display:-webkit-box!important;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;height:calc(3 * 1.3em)!important;font:600 12.75px/1.3 Poppins,sans-serif!important;color:#000!important;text-decoration:none}', G + ' .tile .product-name a:visited{color:#000!important}' + G + ' .tile .product-name a:hover{color:rgb(0,132,61)!important}', G + ' .tile .product-sku{font:400 11.5px Poppins,sans-serif!important;color:#6b7280!important;margin:0 0 4px!important}', G + ' .tile .product-sku strong{font-weight:600!important;color:#6b7280!important;text-transform:none!important}', /* description */ '.eqm-desc{position:relative;font:400 12px/1.12 Poppins,sans-serif!important;color:#000!important;margin:0!important}', '.eqm-desc p{margin:0!important;padding:0!important;display:-webkit-box!important;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font:400 12px/1.12 Poppins,sans-serif!important;color:#000!important}', '.eqm-desc ul{display:none;position:absolute;left:-8px;right:-8px;top:calc(100% + 4px);z-index:20;background:#fff;border:1px solid #d9eee0;border-radius:10px;box-shadow:0 10px 24px rgba(0,0,0,.14);padding:10px 12px 8px;margin:0;list-style:none}', '.eqm-desc.open ul{display:block}', '.eqm-desc ul li{position:relative;padding:0 0 0 12px!important;margin:0!important;font:400 12px/1.15 Poppins,sans-serif!important;color:#000!important}', '.eqm-desc ul li:before{content:"";position:absolute;left:1px;top:.5em;width:5px;height:5px;border-radius:50%;background:#00843d}', '.eqm-more{background:none!important;border:0!important;padding:0!important;margin:2px 0 0!important;height:auto!important;min-height:0!important;font:600 11.5px/1.3 Poppins,sans-serif!important;color:#00843d!important;cursor:pointer;display:inline-flex!important;align-items:center;gap:3px;box-shadow:none!important}', '.eqm-more svg{transition:transform .15s}.eqm-desc.open .eqm-more svg{transform:rotate(180deg)}', /* price */ G + ' .tile .footer-wrapper-price{border-top:1px solid #f0f0f0;padding-top:6px!important;margin-top:6px!important;display:flex!important;flex-direction:column!important;align-items:flex-start!important;gap:0!important;height:auto!important}', '.eqm-pb{display:flex;flex-direction:column;align-items:flex-start;width:100%}', '.eqm-row{display:flex;align-items:baseline;gap:4px}', '.eqm-yp{font:600 10px/1 Arial,sans-serif;color:#6b7280;letter-spacing:.06em;text-transform:uppercase;margin:0 0 1px}', G + ' .tile .price-label{font:800 20px Poppins,sans-serif!important;line-height:1.05!important;height:auto!important;color:#00843d!important}', G + ' .tile .uomvalue{font:500 12px Poppins,sans-serif!important;color:#6b7280!important}', /* quantity + add to cart */ G + ' .tile .buttons.group{display:flex!important;flex-wrap:nowrap!important;gap:6px!important;align-items:center;margin-top:6px!important;height:auto!important}', '.eqm-qty{display:inline-flex;align-items:center;border:1px solid #d1d5db;border-radius:9px;height:42px;overflow:hidden;flex:0 0 auto}', '.eqm-qty button{width:26px;height:42px;border:0;background:#f9fafb;color:#374151;font:600 17px/1 Arial;cursor:pointer}', G + ' .tile .eqm-qty input.qty-list{border:0!important;width:34px!important;height:40px!important;border-radius:0!important;padding:0!important;text-align:center}', G + ' .tile .live-inventory-v2-add-to-cart-wrapper{flex:1 1 auto!important;min-width:0}', G + ' .tile .btn-add-to-cart{width:100%!important;height:42px!important;border-radius:9px!important;background:#00843d!important;border-color:#00843d!important;font:600 13.5px Poppins,sans-serif!important;white-space:nowrap;padding:0 6px!important}', G + ' .tile .btn-add-to-cart:hover{background:#0b4d26!important}', /* V2: Lead Time lines hidden */ G + ' .tile .leadtime,' + G + ' .tile .eqm-lt-hide{display:none!important}', /* V2: fixed slots so every element lines up across a row */ G + ' .tile .product-sku{white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;height:15px!important;line-height:15px!important}', G + ' .tile .eqm-desc{height:44px!important;overflow:visible}', G + ' .tile .eqm-desc.empty{visibility:hidden}', G + ' .tile .indicators-grid:empty{display:none!important}', '.eqm-pb{min-height:33px}', G + ' .tile .buttons.group{min-height:42px!important}', /* V2: Out of Stock hover message */ '.eqm-dl.out{position:relative;cursor:help}', '.eqm-tip{display:none;position:absolute;right:0;top:calc(100% + 6px);z-index:30;padding:6px 9px;border-radius:6px;background:#fff;border:1px solid #e5e7eb;border-left:3px solid #e00000;text-align:left;box-shadow:0 4px 12px rgba(0,0,0,.10)}', '.eqm-tip:before{content:"";position:absolute;right:18px;top:-5px;border:5px solid transparent;border-top:0;border-bottom-color:#e5e7eb}', '.eqm-dl.out:hover .eqm-tip,.eqm-dl.out.tip-on .eqm-tip{display:block}', '.eqm-dl .eqm-tip{white-space:nowrap!important;color:#374151!important;font:400 11px/1.35 Arial,sans-serif!important}', G + ' .tileparent{position:relative}' + G + ' .tileparent:hover,' + G + ' .tileparent:focus-within,' + G + ' .tileparent:has(.tip-on){z-index:6}' ].join('\n'); var TRUCK = ''; var INFO = ''; var HEART = ''; var CHEV = ''; /* logo size by brand (logo files with extra white space need a bigger number) */ var SCALE = { 'Post-it': 1.5, 'Nature Saver': 2.3, 'Quality Park': 1.5, 'ACCO': 1.25, 'Smead': 1.3, 'Pendaflex': 1.3, 'Hammermill': 1.42, 'Business Source': 1.3, 'Central National-Gottesman': 1.2, 'Global Office': 1.05, 'Emerald Special': 1.0 }; /* ---------- 3-line titles ---------- */ /* fractions: halves/quarters as decimals (8.5"), eighths/sixteenths kept (2 5/8"), anything else as 2 decimals (3.33") */ function num(t) { var m = /^(\d+)(?:[ -](\d+)\/(\d+))?$/.exec(t) || null, w, n, d; if (m) { w = +m[1]; n = m[2] ? +m[2] : 0; d = m[3] ? +m[3] : 1; } else if ((m = /^(\d+)\/(\d+)$/.exec(t))) { w = 0; n = +m[1]; d = +m[2]; } else return t; if (!n) return String(w); if (d === 2 || d === 4) return String(+(w + n / d).toFixed(2)); if (d === 8 || d === 16) return (w ? w + ' ' : '') + n + '/' + d; return String(+(w + n / d).toFixed(2)); } var NUM = '(\\d+[ -]\\d+\\/\\d+|\\d+\\/\\d+|\\d+(?:\\.\\d+)?)'; var CW = /\b(pink|yellow|green|blue|orange|purple|mint|aqua|lime|limeade|guava|papaya|sunnyside|moonstone|canary|red|white|black|gray|grey|kraft|manila|assorted|navy|brown|teal|violet|clear|ivory|tan)\b/i; function dims(s) { if (!/ x /i.test(s)) return ''; var m = [], re = new RegExp(NUM + '"(?: \\((\\d+) ft\\))?', 'g'), x; while ((x = re.exec(s))) m.push(x); if (m.length < 2) return ''; var f = function (x) { return x[2] ? x[2] + "'" : num(x[1]) + '"'; }; return f(m[0]) + ' x ' + f(m[1]); } var HAS_SIZE = /\d[\d\/ .-]*"?\s*x\s*\d/i; var SKIP_EXTRA = /Height|Width|Length|Diameter|Brightness|Basis Weight|Capacity|Expansion|Divider|^(Rectangle|Square|Paper|Self-adhesive|Self-stick|Recyclable|Recycled|Durable|Removable|Writable)$|^1 (Each|Pack|Box)$/i; function build(n, uom) { var seg = n.split(' - ').map(function (s) { return s.trim(); }).filter(Boolean); var base = seg.shift().replace(/®|™/g, '').replace(/^Post-it Post[- ]it /i, 'Post-it ').replace(/\s+,/g, ',').replace(/\s+/g, ' '); base = base.replace(/^(LETTER|LEGAL) SIZE /i, '').replace(/-\s*\d+ Ream$/i, '').trim(); /* tidy fractions written inside the product name: 2-5/8" -> 2 5/8", 1-1/3" -> 1.33" */ base = base.replace(new RegExp(NUM + '"', 'g'), function (a, b) { return num(b) + '"'; }); base = base.replace(/"\s*x\s*(?=\d)/gi, '" x ').replace(/\s+,/g, ','); var size = '', cap = '', div = '', color = '', sheets = '', lb = '', br = '', packs = [], used = {}, extras = []; seg.forEach(function (s, i) { if (!size && dims(s)) { size = dims(s); used[i] = 1; } else if (!cap && /(Expansion|Folder Capacity)$/i.test(s)) { cap = s.replace(/Folder Capacity/i, 'Capacity'); used[i] = 1; } else if (!div && /^\d+ Divider$/i.test(s)) { div = s.replace(/Divider$/, +s.match(/\d+/)[0] > 1 ? 'Dividers' : 'Divider'); used[i] = 1; } else if (!lb && /^\d+ lb( Basis Weight)?$/i.test(s)) { lb = s.replace(/ Basis Weight/i, ''); used[i] = 1; } else if (!br && /^\d+ Brightness$/i.test(s)) { br = s.replace('Brightness', 'Bright'); used[i] = 1; } else if (!sheets && !/per Ream/i.test(n) && /^\d+ Sheets( per Pad)?$/i.test(s)) { sheets = s.replace(' per ', '/'); used[i] = 1; } else if (!color && CW.test(s) && !/\d|surface|film|sheet color|paper|pressboard|tyvek|reinforced|recycled|stick|collection/i.test(s)) { color = s.split(',').length > 2 ? 'Assorted Colors' : s; used[i] = 1; } else if (/^[\d,]+ \/ \w+$/.test(s) && !/^1 \//.test(s)) { packs.push(s.replace(' / ', '/')); used[i] = 1; } }); if (HAS_SIZE.test(base)) size = ''; var low = base.toLowerCase(); if (color && low.indexOf(color.toLowerCase()) !== -1) color = ''; /* the pack that matches how it's sold (BX = Box, PK = Pack, CT = Carton...) goes first; packs already in the name are skipped */ var UOMW = { BX: 'Box', PK: 'Pack', CT: 'Carton', CS: 'Case', RL: 'Roll', RM: 'Ream', DZ: 'Dozen', EA: 'Each', ST: 'Set', PD: 'Pad', BG: 'Bag', TB: 'Tub' }; packs = packs.filter(function (p) { var q = p.split('/')[0].replace(/,/g, ''); return !new RegExp('(^|\\D)' + q + '[ ,]*(ct|count|labels|sheets|total)', 'i').test(base.replace(/,(?=\d{3})/g, '')); }); var w = UOMW[(uom || '').toUpperCase()]; if (w) packs.sort(function (x, y) { return (new RegExp('/' + w + '$', 'i').test(y) ? 1 : 0) - (new RegExp('/' + w + '$', 'i').test(x) ? 1 : 0); }); var pack = packs.shift() || ''; if (pack && /per Ream/i.test(n)) pack = pack.replace('/', ' Reams/'); /* details that can fill a short title, in the order they appear */ packs.forEach(function (p) { extras.push(p); }); seg.forEach(function (s, i) { if (used[i] || SKIP_EXTRA.test(s) || s.length > 28 || (s.match(/,/g) || []).length > 1 || /\d+ \/ \w+/.test(s)) return; if (low.indexOf(s.toLowerCase()) !== -1) return; extras.push(s); }); var parts = [base, size, lb, cap, div, sheets, color, br, pack].filter(Boolean); return { parts: parts, extras: extras, drops: [sheets, br, color, lb, cap].filter(Boolean) }; } function lines(a) { var lh = parseFloat(getComputedStyle(a).lineHeight) || 16.6; a.style.setProperty('display', 'block', 'important'); a.style.setProperty('height', 'auto', 'important'); a.style.setProperty('-webkit-line-clamp', 'unset', 'important'); var h = a.scrollHeight; a.style.removeProperty('display'); a.style.removeProperty('height'); a.style.removeProperty('-webkit-line-clamp'); return Math.round(h / lh); } /* exactly 3 lines: drop the least important detail while too long, add details while too short */ function fit(a) { var b = a._eqm; if (!b || !a.offsetParent || a._eqmW === a.clientWidth) return; a._eqmW = a.clientWidth; var parts = b.parts.slice(), set = function () { var t = parts.join(', '); if (a.textContent !== t) a.textContent = t; }; set(); b.drops.forEach(function (d) { if (lines(a) > 3 && parts.indexOf(d) > 0) { parts.splice(parts.indexOf(d), 1); set(); } }); for (var i = 0; i < b.extras.length && lines(a) < 3; i++) { parts.push(b.extras[i]); set(); if (lines(a) > 3) { parts.pop(); set(); } } } /* ---------- delivery (follows live inventory) ---------- */ function renderDl(tile) { var bl = tile.querySelector('.brand-label'), sh = tile.querySelector('.live-inventory-v2-shipping'); if (!bl) return; var d = bl.querySelector('.eqm-dl'); if (!sh) { if (d) d.remove(); return; } var m = /(\d[\d,]*)\s*In Stock/i.exec(sh.textContent || ''); var out = /out of stock/i.test(sh.textContent || '') || /out-stock/.test(sh.className); if (!m && !out) { if (d) d.remove(); return; } var tip = 'Temporarily out of stock.\nAlternatives? Call 800-587-4601'; var h = m ? '' + TRUCK + 'Next Day Delivery' + m[1] + ' in stock' : '' + INFO + 'Out of Stock'; if (!d) { d = document.createElement('div'); bl.appendChild(d); } if (d.getAttribute('data-h') !== h) { d.setAttribute('data-h', h); d.className = 'eqm-dl ' + (m ? 'in' : 'out'); d.innerHTML = h; if (!m) { var tp2 = d.querySelector('.eqm-tip'); tip.split('\n').forEach(function (ln, k) { if (k) tp2.appendChild(document.createElement('br')); tp2.appendChild(document.createTextNode(ln)); }); tip = tip.replace('\n', ' '); d.setAttribute('tabindex', '0'); d.setAttribute('aria-label', 'Out of Stock. ' + tip); } } if (!d._eqmTap) { d._eqmTap = 1; d.addEventListener('click', function (e) { if (!d.classList.contains('out')) return; e.preventDefault(); e.stopPropagation(); d.classList.toggle('tip-on'); }); } } /* any "Lead Time:" line on the card is hidden; its text is kept for the Out of Stock hover message */ function leadTime(tp, tile) { var lt = (tp.getAttribute('data-leadtime') || '').trim(); tile.querySelectorAll('.leadtime, .footer-wrapper-description > div, .footer-wrapper-description > p').forEach(function (el) { var t = (el.textContent || '').trim(); if (/^Lead Time\s*:/i.test(t)) { if (!lt) lt = t.replace(/^Lead Time\s*:\s*/i, ''); el.classList.add('eqm-lt-hide'); } }); lt = lt.replace(/\bBus\.? Days\b/i, 'business days').replace(/\.$/, ''); if (lt) tile.setAttribute('data-eqm-lt', lt); } function card(tp) { var tile = tp.querySelector('.tile'); if (!tile || tile.getAttribute('data-eqm')) return; tile.setAttribute('data-eqm', '1'); var name = tp.getAttribute('data-item-name') || ''; var im = tile.querySelector('.product-tile-image'); if (im && !im.querySelector('.eqm-heart')) { var h = document.createElement('button'); h.type = 'button'; h.className = 'eqm-heart'; h.title = 'Add to Favorites List'; h.setAttribute('aria-label', 'Add to Favorites List'); h.innerHTML = HEART; h.addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); var f = tile.querySelector('.addtoquicklist'); if (f) f.click(); }); im.appendChild(h); } var lg = tile.querySelector('.brand-label>a>img'); if (lg) lg.style.transform = 'translateY(-50%) scale(' + (SCALE[lg.alt] || 1.15) + ')'; leadTime(tp, tile); renderDl(tile); var sh = tile.querySelector('.live-inventory-v2-shipping'); if (sh) new MutationObserver(function () { renderDl(tile); }).observe(sh, { childList: true, characterData: true, subtree: true, attributes: true }); var na = tile.querySelector('.product-name a'); if (na && name) { na._eqm = build(name, tp.getAttribute('data-pack-uom')); na.textContent = na._eqm.parts.join(', '); } var lis = [].map.call(tile.querySelectorAll('.product-points li'), function (l) { return l.textContent.trim(); }).filter(Boolean); if (lis.length && !tile.querySelector('.eqm-desc')) { var d = document.createElement('div'); d.className = 'eqm-desc'; d.innerHTML = '