';//end row
$('#quickview_replace_content').html(content);
parentItem.childItems = data.childItems;
$('#modal_item_quantity').val('');
modalCurrentAttributes = [];
active_modal_child = {};
drawModalSelects(parentItem, JSON.search(data.childItems, '//attributes'), false);
if(!parentItem.one_item) { disableModalControls(); }
else { active_modal_child = data.childItems[0]; updateProductModal(active_modal_child); activateModalControls(); }
});
}
//console.log(data);
});
}
};
/*-----------------------------------------------------------------------------------------------
/ FOR GROUPS OF `subLinks`:
/ FROM LEFT -> RIGHT, EACH ARRAY IS A 50% WIDTH DIV FOR DESKTOP (LEAVE EMPTY TO SKIP A SPOT)
/ ORDER OF ARRAYS IS IRRELEVANT FOR MOBILE
/----------------------------------------------------------------------------------------------*/
$(document).ready(function() {
$('.comment-link').on('click', function(e) {
e.preventDefault();
var content = $(this).next('.comment-content');
var icon = $(this).find('.comment-icon');
if(content.is(':visible')) {
content.hide();
icon.removeClass('fa-caret-up').addClass('fa-caret-down');
} else {
content.show();
icon.removeClass('fa-caret-down').addClass('fa-caret-up');
}
});
if(navigation_json) {
//Fill the first level of navigation
var bootstrapPopoverTemplate = '
';
var bootstrapPopoverOptions = { placement: 'bottom', html: true, animation: false, content: firstLevelNavigation, template: bootstrapPopoverTemplate, trigger: 'manual' };
}
//--------------------------------------------------------------------------------------
//Top Level Navigation Popover
//--------------------------------------------------------------------------------------
$('#shop-products-btn, #shop-btn-scroll').popover( bootstrapPopoverOptions ).click(function(e){
e.preventDefault();
}).on("mouseenter", function () {
//Check to see if the navigation is already displayed
if(!$(this).hasClass('products-btn-active')) {
//Display the top level navigation
var _this = this;
$(this).popover("show");
$(this).addClass('products-btn-active');
$('.nav-overlay').show();
$(this).siblings(".popover").on("mouseleave", function () {
if(!$("#shop-products-btn:hover").length) {
$(_this).popover('hide');
}
});
}
else {
//Navigation is already shown, hide the flyout & remove the active caret
$('.under-header').find('#flyout-caret').remove();
$('.nav-flyout').animate({ left: "0%"}, 200, function() { $('.nav-flyout').hide(); });
}
$("#search-results ul").html("");
}).on("mouseleave", function () {
//If they mouseover the popover, keep it alive, if not hide it
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 200);
}).on('hidden.bs.popover', function () {
//Fires when popover has been hidden
//Remove active class from the shop button & hide the overlay
$(this).removeClass('products-btn-active');
$('.nav-overlay').hide();
});
//--------------------------------------------------------------------------------------
//Navigation Flyout Event Listener
//DESKTOP ONLY
//Handles the second level of navigation + animation of flyout
//--------------------------------------------------------------------------------------
var cachedContent = [];
$('body').on('click', '.products-nav .list-group-item a', function(e) {
//FLYOUT DISPLAY & ANIMATION
//Check to see if the nav flyout is visible
//e.preventDefault();
if( !$('.nav-flyout').is(':visible') && !$(this).attr('data-custom-link'))
{
//Not visible: show the flyout & animate it to the right
$('.nav-flyout').show();
$('.nav-flyout').animate({ left: "100%"}, 200);
}
//FLYOUT CONTENT & BACKGROUND
var caret = '';
var list_index = $(this).index();
var original_width = '450px'; //original width for nav flyout
var flye = $('.nav-flyout'); //set variable for nav flyout element
//Find the old caret and remove it
$('.under-header').find('#flyout-caret').remove();
//Find new link and add caret to end
$(this).children('a').append( caret );
//Replace flyout html with new content & background image
var linkIndex = $(this).attr('data-linkIndex');
var subLinks = null;
if(cachedContent[linkIndex]){ var flyoutContent = cachedContent[linkIndex]; }
else {
subLinks = navigation_json[linkIndex];
//console.log(subLinks);
var flyoutContent = '';
flyoutContent += '
';
var bootstrapMobileOptions = {
placement: 'bottom',
html: true,
animation: false,
content: bootstrapMobileContent,
template: bootstrapMobileTemplate,
trigger: 'manual'
};
$('#shop-products-btn-sm').popover( bootstrapMobileOptions ).on("click", function (e) {
e.preventDefault();
//Show the top level categories on click
var _this = this;
$(this).popover("show");
$(this).addClass('products-btn-active');
$(this).siblings(".popover").on("mouseleave", function () {
if(!$("#shop-products-btn-sm:hover").length) {
$(_this).popover('hide');
}
});
}).on("mouseleave", function () {
//Hide the navigation when the mouse leaves popover
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
}).on('hidden.bs.popover', function () {
//POPOVER HIDDEN
//Remove active styling from the button
$(this).removeClass('products-btn-active');
});
//Mobile Sub Categories
$('.under-header').on('click', '.products-nav-mobile .sub-header-mobile', function(e) {
//Hide/Display sub categories for mobile devices
e.preventDefault();
var sub_cats = $(this).siblings('.sub-cat'); //Grab the current sub category
sub_cats.slideToggle(250); //Display the sub categories for link clicked
$('.sub-cat').not(sub_cats).slideUp(200); //Hide all the other ones
});
//Show scrolling nav on scroll
$(window).scroll(function(){
if($(this).scrollTop() > 135) {
$('.scroll-nav').show();
}
else {
$('.scroll-nav').hide();
}
});
$(window).scroll(function() {
if($('#sticky-anchor').length) {
var window_top = $(window).scrollTop();
var div_top = $('#sticky-anchor').offset().top;
var width = $(window).width();
if (window_top >= div_top && width >= 768)
{
$('#sticky-tabs-container').addClass('sticky');
$('#sticky-product-bar').addClass('sticky');
} else {
$('#sticky-tabs-container').removeClass('sticky');
$('#sticky-product-bar').removeClass('sticky');
}
}
});
$('#top-of-page, #back-to-top, #options-btn-back-top, a.back-to-top').click(function(){
$('html, body').velocity('scroll', {
duration:500,
offset:0,
easing: 'ease-in-out'
});
});
//---------------------------------------------------------------------------------------------------------------
//Account Dropdown
//---------------------------------------------------------------------------------------------------------------
$('#btn-account-nav').hover(function() {
$(this).css('background-color', '#d63a3a');
var id = $(this).attr('id');
var popoverTemplateAccount = '
';
var popover_options = { placement: 'bottom', html: true, animation: false, content: accountPopoverContent, template: popoverTemplateAccount, trigger: 'manual' };
$(this).popover( popover_options );
$(this).next(".popover").on("mouseleave", function () { $(this).popover('hide'); });
$(this).css("color", "#fff");
$(this).popover("show").on("mouseleave", function () {
//If they mouseover the popover, keep it alive, if not hide it
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
}).on('hidden.bs.popover', function () {
//Fires when popover has been hidden
$(this).css('background', 'none');
if(id == 'btn-account-nav')
{
$(this).css('color', '#fff');
}
else if(id == 'btn-account-scroll-nav')
{
$(this).css('color', '#555');
}
});
if(document.getElementById('loginFormDropdown')) {
$('#loginFormDropdown').parsley({'errorsMessagesDisabled': true, 'excluded': 'input[type=button],input[type=submit],input[type=reset]'});
}
});
//--------------------------------------------------------------------------------------------------------------
//Help Dropdown
//--------------------------------------------------------------------------------------------------------------
$('#btn-help-nav').hover(function() {
$(this).css('background-color', '#d63a3a');
var id = $(this).attr('id');
var popoverTemplateHelp = '
';
//helpPopoverContent = $('#help-dropdown-content').html();
var popover_options = { placement: 'bottom', html: true, animation: false, content: helpPopoverContent, template: popoverTemplateHelp, trigger: 'manual' };
$(this).popover( popover_options );
$(this).next(".popover").on("mouseleave", function () { $(this).popover('hide'); });
$(this).css("color", "#fff");
$(this).popover("show").on("mouseleave", function () {
//If they mouseover the popover, keep it alive, if not hide it
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
}).on('hidden.bs.popover', function () {
//Fires when popover has been hidden
$(this).css('background', 'none');
if(id == 'btn-account-nav')
{
$(this).css('color', '#fff');
}
else if(id == 'btn-account-scroll-nav')
{
$(this).css('color', '#555');
}
});
if(document.getElementById('loginFormDropdown')) {
$('#loginFormDropdown').parsley({'errorsMessagesDisabled': true, 'excluded': 'input[type=button],input[type=submit],input[type=reset]'});
}
});
//--------------------------------------------------------------------------------------------------------------
//Custom products Dropdown
//--------------------------------------------------------------------------------------------------------------
$('#btn-custom-nav').hover(function() {
$(this).css('background-color', '#d63a3a');
var id = $(this).attr('id');
var popoverTemplateHelp = '
';
//helpPopoverContent = $('#help-dropdown-content').html();
var popover_options = { placement: 'bottom', html: true, animation: false, content: customProductsPopoverContent, template: popoverTemplateHelp, trigger: 'manual' };
$(this).popover( popover_options );
$(this).next(".popover").on("mouseleave", function () { $(this).popover('hide'); });
$(this).css("color", "#fff");
$(this).popover("show").on("mouseleave", function () {
//If they mouseover the popover, keep it alive, if not hide it
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
}).on('hidden.bs.popover', function () {
//Fires when popover has been hidden
$(this).css('background', 'none');
if(id == 'btn-account-nav')
{
$(this).css('color', '#fff');
}
else if(id == 'btn-account-scroll-nav')
{
$(this).css('color', '#555');
}
});
});
//Hide navigation when modal is opened
//Show navigation when closed
if($(window).scrollTop() > 135) {
$('.scroll-nav, #sticky-tabs-container').show();
}
$('.modal').on('show.bs.modal', function(e) {
var scroll_nav = $('.scroll-nav');
var sticky_tabs = $('#sticky-tabs-container');
if(scroll_nav.length){ $('.scroll-nav').hide(); }
if(sticky_tabs.length){ $('#sticky-tabs-container').hide(); }
}).on('hide.bs.modal', function(e) {
if($(window).scrollTop() > 135) {
$('.scroll-nav, #sticky-tabs-container').show();
}
});
$('#show-shipping-modal').on('click', function(e) {
e.preventDefault();
$('#shipping-info-modal').modal('show');
});
});
//------------------------------------------------------------------------------------------------------------------
//JAVASCRIPT FORM VALIDATION
//Override Parsley's normal error handlers
//------------------------------------------------------------------------------------------------------------------
if($('form.parsley-form').length) {
$('form.parsley-form').parsley({'errorsMessagesDisabled': true, 'excluded': 'input[type=button],input[type=submit],input[type=reset], :hidden'});
if($('.parsley-form-reset-btn').length) {
$('.parsley-form-reset-btn').on('click', function(e) {
$('form.parsley-form').parsley().reset();
$('form.parsley-form input[type=text], form.parsley-form textarea').val('');
$('div.error-box').remove();
});
}
}
window.Parsley.on('field:error', function (fieldInstance) {
var currentError = $(fieldInstance.$element).next();
if(currentError.hasClass('error-box')) {
currentError.html( fieldInstance.getErrorsMessages().join(';') );
}
else {
$('