@baseTemplate

jQuery(function ($) {
    'use strict';
    // fix bootstrap hide event
    $('.navbar-collapse').each(function () {
        this.hide = undefined;
    });

    // menu
    $('.h-nav').find('ul').addClass('nav nav-pills nav-stacked');

    // search form
    $('form.bd-search').parent('.bd-textblock').css('overflow', 'visible');
    // shopping cart product name
    $('#shopping-cart-table h2.product-name a').unwrap();
    $('.bd-shoppingtable').find('.button').removeClass('button').addClass('bd-shoppingtable-button');

    // buttons
    $('button.button').removeClass('button');//.addClass('bd-button');

    // header cart sliding

    var hideTimeout;
    var hideDetails = function () {
        hideTimeout = setTimeout(function() {
            $('#bd-mini-cart .bd-shoppingcart').slideUp(500);
        }, 500);
    };

    $('#bd-mini-cart .bd-minicart-summary').mouseenter(function () {
        clearTimeout(hideTimeout);
        $('#bd-mini-cart .bd-shoppingcart').slideDown(500);
    }).mouseleave(function () {
        hideDetails();
    });

    $('#bd-mini-cart .bd-shoppingcart').mouseenter(function () {
        clearTimeout(hideTimeout);
    }).mouseleave(function () {
        hideDetails();
    });
});

function productsGridReload(url) {
    'use strict';

    jQuery('#ajax-loader').show();
    jQuery('#product-list').addClass('ajax-disabled');

    jQuery.ajax({
        type: 'GET',
        url: url,
        data: { ajax: 1 },
        dataType: 'html',
        success: function (response) {
            var dfds = [];
            jQuery('#ajax-loader').hide();
            jQuery('#product-list').replaceWith(response);
            jQuery('#product-list').find('img').each(function () {
                if (this.complete) return;
                var dfd = jQuery.Deferred();
                jQuery(this).load(dfd.resolve);
                dfds.push(dfd.promise());
            });

            var obj = jQuery('body').data('typeSelector');
            jQuery.when.apply(jQuery, dfds).done(function () {
                obj.updateLayout(window.designer.grid.itemsInRow);
            });

            jQuery(window).resize();
        },
        error: function (xhr) {
            jQuery('#ajax-loader').hide();
            jQuery('#product-list').removeClass('ajax-disabled');
            window.console.log(xhr.status);
        }
    });
}