$(document).ready(function() { $('#why-usmb-link').on('click', function(e) { e.preventDefault(); var whyTitle = $('#why-usmb-title').offset().top; $('html, body').animate({ scrollTop: whyTitle-60 }, 500); /*$('html, body').velocity('scroll', { duration:600, offset:whyTitle.top, easing: 'ease-in-out' });*/ }); $('.popup-link').on('click', function(e) { e.preventDefault(); }); var popperContentSettings = { placement:'bottom-start', html:true, modifiers: { flip: { enabled: false } } }; //------------------------------------------------------------------------------------------------------------ // Accont popup //------------------------------------------------------------------------------------------------------------ var accountLink = $('#account-link'); var accountContent = $('#account-popup'); accountLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); accountContent.show(); var popper = new Popper(accountLink, accountContent, popperContentSettings); }).on('mouseleave', function() { setTimeout(function() { if(!accountContent.is(':hover')) { accountContent.hide(); } }, 300); }); accountContent.on('mouseleave', function() { setTimeout(function() { if(!accountContent.is(':hover') && !accountLink.is(':hover')) { accountContent.hide(); } }, 200); }); //------------------------------------------------------------------------------------------------------------ // Resources popup //------------------------------------------------------------------------------------------------------------ var resourcesLink = $('#resources-link'); var resourcesContent = $('#resources-popup'); resourcesLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); resourcesContent.show(); resourcesLink.addClass('popup-active'); var popper = new Popper(resourcesLink, resourcesContent, popperContentSettings); }).on('mouseleave', function() { setTimeout(function() { if(!resourcesContent.is(':hover')) { resourcesContent.hide(); resourcesLink.removeClass('popup-active'); } }, 300); }); resourcesContent.on('mouseleave', function() { setTimeout(function() { if(!resourcesContent.is(':hover') && !resourcesLink.is(':hover')) { resourcesContent.hide(); resourcesLink.removeClass('popup-active'); } }, 200); }); //------------------------------------------------------------------------------------------------------------ // Who we serve popup //------------------------------------------------------------------------------------------------------------ var serveLink = $('#who-we-serve-link'); var serveContent = $('#who-we-serve-popup'); serveLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); serveContent.show(); serveLink.addClass('popup-active'); var popper = new Popper(serveLink, serveContent, popperContentSettings); }).on('mouseleave', function() { setTimeout(function() { if(!serveContent.is(':hover')) { serveContent.hide(); serveLink.removeClass('popup-active'); } }, 300); }); serveContent.on('mouseleave', function() { setTimeout(function() { if(!serveContent.is(':hover') && !serveLink.is(':hover')) { serveContent.hide(); serveLink.removeClass('popup-active'); } }, 200); }); whoWeServeContent = []; whoWeServeContent['schools'] = 'We can outfit entire schools with whiteboards, furniture and all the lab equipment you need.'; whoWeServeContent['homes'] = 'Home owners can find or build whatever they need to their specifications.'; whoWeServeContent['offices'] = 'Run an office? We have everything from office chairs to shredders to shelving/storage.'; whoWeServeContent['hospitals'] = 'We make high quality custom sized hospital curtains exactly the size you need.'; whoWeServeContent['churches'] = 'If you are on a budget, our quote process can save you money.'; whoWeServeContent['architects'] = 'We can often get quantity discounts if you are planning a large scale project.'; $('.serve-item').on('mouseenter', function() { var serveItem = $(this).attr('data-serve-item'); if(serveItem && whoWeServeContent[serveItem]) { $('#who-we-serve-popup .hover-info').show(); $('#who-we-serve-popup .hover-info').html(' ' + whoWeServeContent[serveItem]); } else { $('#who-we-serve-popup .hover-info').hide(); } }).on('mouseleave', function() { $('#who-we-serve-popup .hover-info').hide(); }); //------------------------------------------------------------------------------------------------------------ // Custom Products popup //------------------------------------------------------------------------------------------------------------ var customLink = $('#custom-products-link'); var customContent = $('#custom-products-popup'); customLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); customContent.show(); customLink.addClass('popup-active'); var popper = new Popper(customLink, customContent, popperContentSettings); }).on('mouseleave', function() { setTimeout(function() { if(!customContent.is(':hover')) { customContent.hide(); customLink.removeClass('popup-active'); } }, 300); }); customContent.on('mouseleave', function() { setTimeout(function() { if(!customContent.is(':hover') && !customLink.is(':hover')) { customContent.hide(); customLink.removeClass('popup-active'); } }, 200); }); //------------------------------------------------------------------------------------------------------------ // Top Products popup //------------------------------------------------------------------------------------------------------------ var topLink = $('#top-products-link'); var topContent = $('#top-products-popup'); topLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); topContent.show(); topLink.addClass('popup-active'); var popper = new Popper(topLink, topContent, popperContentSettings); }).on('mouseleave', function() { setTimeout(function() { if(!topContent.is(':hover')) { topContent.hide(); topLink.removeClass('popup-active'); } }, 300); }); topContent.on('mouseleave', function() { setTimeout(function() { if(!topContent.is(':hover') && !topLink.is(':hover')) { topContent.hide(); topLink.removeClass('popup-active'); } }, 200); }); //------------------------------------------------------------------------------------------------------------ // Shop by category functions //------------------------------------------------------------------------------------------------------------ var shopByCatLink = $('.shop-by-category'); var shopByCatContent = $('#shop-categories-popup'); var cacheNavContent = []; shopByCatLink.hover( function(e) { $('.content-popup, .nav-popup').hide(); shopByCatContent.show(); shopByCatLink.addClass('popup-active'); var popper = new Popper(shopByCatLink, shopByCatContent, { placement:'bottom-start', html:true, modifiers: { flip: { enabled:false } } }); }).on('mouseleave', function() { setTimeout(function() { if(!shopByCatContent.is(':hover')) { shopByCatContent.hide(); shopByCatLink.removeClass('popup-active'); } }, 200); }); shopByCatContent.on('mouseleave', function() { setTimeout(function() { if(!shopByCatContent.is(':hover') && !shopByCatLink.is(':hover')) { shopByCatContent.hide(); shopByCatLink.removeClass('popup-active'); } }, 200); }); if(typeof navigation_content != 'undefined') { var initialActive = $('.sbc-link.active').attr('data-content-id'); var initialContent = buildCategoryContent(initialActive, navigation_content[initialActive], 'c/boards'); $('#shop-category-content').html(initialContent); } $('.sbc-link').hover(function() { $('.sbc-link').removeClass('active'); $(this).addClass('active'); var content_id = $(this).attr('data-content-id'); var shop_all = $(this).attr('data-shop-all'); if(cacheNavContent[content_id]) { var category_content = cacheNavContent[content_id]; } else { if(navigation_content[content_id]) { var category_content = buildCategoryContent(content_id, navigation_content[content_id], shop_all); } else { var category_content = '