`,
searchspring_category_path: `Gift Making Guide>Board Games`,
categoryHasChildren: false,
searchspring_siteId: `rn129l`,
searchspring_excludedCategories: `Shop By Brand,New Products,Woodworker's Journal,Rockler Promotions,Outlet Store,Build It With Rockler,Gift Making Guide,Holiday Gift Guide,Father's Day Gift Guide`,
categoryChildrenImages: [] || [],
base_url: `https://www.rockler.com/`,
media_url: `https://www.rockler.com/media/`,
imageUrlsPreload: [] || [],
productImageUrl: ``,
showSubcategoriesSlider: parseInt(`1`),
};
window.storeConfig = {"homepageIdentifier":"home"} || {};
window.contentConfiguration = {"contact_us_content":{"contact_us_cms_block":"contact_us_page_block"},"footer_content":{"footer_cms":null},"minicart_content":{"minicart_cms":null},"cart_content":{"cart_cms":null},"checkout_content":{"checkout_shipping_cms":null,"checkout_billing_cms":null,"checkout_top_cms":null},"header_content":{"header_menu":"rockler-main-menu","header_mobile_menu":"rockler-mobile-menu","contacts_cms":null,"enable_header_usps":"0"},"product_list_content":{"attribute_to_display":null},"cookie_content":{"cookie_text":null,"cookie_link":null}} || {};
// Multistore
// do reverse sort in order prevent an issue like store code `en` replaces store code `en_us`
window.storeList = JSON.parse(`["default","rockler_pro"]`).sort().reverse();
window.storeRegexText = `/(${window.storeList.join('|')})?`;
// vvv Generate preload links
const chunkValidator = {
//vvv Preload pages conditionally
category: window.actionName.type === 'CATEGORY',
cms: window.actionName.type === 'CMS_PAGE',
product: window.actionName.type === 'PRODUCT',
render: true,
//vvv Always preload current locale
[window.defaultLocale]: true
};
const appendPreloadLink = (chunk) => {
const link = document.createElement('link');
link.rel = 'preload';
link.as = 'script';
link.href = chunk;
document.head.appendChild(link);
}
if (window.preloadData) {
Object.entries(window.preloadData).forEach(([key, chunks]) => {
if (chunkValidator[key]) {
chunks.forEach((c) => appendPreloadLink(c));
}
});
}
const preloadImage = (imageUrl) => {
const link = document.createElement('link');
link.rel = 'preload';
link.as = 'image';
link.href = imageUrl;
document.head.appendChild(link);
};
if (window.actionName.type === 'CMS_PAGE') {
if (window.actionName.imageUrlsPreload.length) {
if (window.innerWidth > 810) {
preloadImage(window.actionName.imageUrlsPreload?.[0]);
} else {
preloadImage(window.actionName.imageUrlsPreload?.[1]);
}
}
}
if (window.actionName.type === 'PRODUCT') {
preloadImage(window.actionName.productImageUrl);
}
const getCategoryDetailsPlaceholderCount = () => {
width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
if (width < 811) {
return -1;
}
if (width < 891) {
return 4;
}
if (width < 1101) {
return 5;
}
if (width < 1276) {
return 6;
}
return 7;
};
const media = (src, subPath = '', isMediaPath = true) => {
// If isMediaPath is passed return local media path
const baseUrl = isMediaPath ?
window.actionName.media_url || '/media/' :
window.actionName.base_url;
return `${ baseUrl }${ subPath }${ src }`;
};
if (window.actionName.type === 'CATEGORY') {
if (window.actionName.showSubcategoriesSlider) {
if (window.actionName.categoryChildrenImages?.length && window.actionName?.categoryHasChildren) {
window.actionName.categoryChildrenImages.forEach((image, index) => {
if (index < getCategoryDetailsPlaceholderCount()) {
const isImageValid = true && image;
const imageIncludesMedia = isImageValid ? image.includes('media') : false;
const imageFormatted = imageIncludesMedia ?
media(image.substring(1), '', false) :
media(image, 'catalog/category/');
preloadImage(imageFormatted);
}
});
}
}
}